Backport #7996
closedNon-existent code page on certain windows XP versions
Description
Hello,
I try to run ruby 2.0.0p0 on a machine having Windows XP embedded. This causes a core dump. I tracked to problem to "win32/file.c", convert_mb_to_wchar.
Here the conversion is done from ascii 7 bit to wchar using MultiByteToWideChar. This function returns 0 (instead of the length) as this Windows XP embedded has no coding support for code page 20217(us ascii). So MultiByteToWideChar returns an error indicating failure.
I changed the default coding page to 1252 as this is supported on all windows versions and this coding page should be identical with ascii 7 bit for the range 0x20-0x7f (or am I wrong here?)
So I made this patch which works fine:
diff -rupN ruby-2.0.0-p0/win32/file.c ruby-2.0.0-p0.new/win32/file.c
--- ruby-2.0.0-p0/win32/file.c 2012-11-17 18:53:21 +0100
+++ ruby-2.0.0-p0.new/win32/file.c 2013-02-28 11:43:29 +0100
@@ -212,9 +212,10 @@ code_page(rb_encoding *enc)
names_ary = rb_funcall(encoding, names, 0);
}
- /* map US-ASCII and ASCII-8bit as code page 20127 (us-ascii) */
- /* map US-ASCII and ASCII-8bit as code page 1252 (us-ascii) */
- /* code page 20127 (us-ascii) is not available on older WinXP systems*/
if (enc == rb_usascii_encoding() || enc == rb_ascii8bit_encoding()) {
- UINT code_page = 20127;
- UINT code_page = 1252;
rb_hash_aset(rb_code_page, name_key, INT2FIX(code_page));
return code_page;
}
- Michael