Backport #7996

Non-existent code page on certain windows XP versions

Added by Michael Meltner about 1 year ago. Updated about 1 year ago.

[ruby-core:53079]
Status:Closed
Priority:Normal
Assignee:Tomoyuki Chikanaga

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", convertmbto_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 @@ codepage(rbencoding *enc)
namesary = rbfuncall(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 == rbusasciiencoding() || enc == rbascii8bitencoding()) {
  • UINT code_page = 20127;
  • UINT codepage = 1252;
    rb
    hashaset(rbcodepage, namekey, INT2FIX(codepage));
    return code
    page;
    }

  • Michael

Associated revisions

Revision 40293
Added by Tomoyuki Chikanaga about 1 year ago

merge revision(s) 40003: [Backport #7996]

* win32/file.c (code_page): use cp1252 instead of cp20127 as US-ASCII.
  fix  [Bug #7996]
  reported and patched by mmeltner (Michael Meltner).
  reported by mitchellh (Mitchell Hashimoto).

History

#1 Updated by Yui NARUSE about 1 year ago

  • Tracker changed from Backport to Bug
  • Project changed from Backport200 to ruby-trunk
  • Status changed from Open to Assigned
  • Assignee set to Usaku NAKAMURA

#2 Updated by Usaku NAKAMURA about 1 year ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40003.
Michael, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • win32/file.c (code_page): use cp1252 instead of cp20127 as US-ASCII. fix [Bug #7996] reported and patched by mmeltner (Michael Meltner).

#3 Updated by Tomoyuki Chikanaga about 1 year ago

  • Tracker changed from Bug to Backport
  • Project changed from ruby-trunk to Backport200
  • Status changed from Closed to Assigned
  • Assignee changed from Usaku NAKAMURA to Tomoyuki Chikanaga

I think this is a regression of 2.0.0, because fixed lines are introduced at r36811 (2012-08-24).

#4 Updated by Tomoyuki Chikanaga about 1 year ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40293.
Michael, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 40003: [Backport #7996]

* win32/file.c (code_page): use cp1252 instead of cp20127 as US-ASCII.
  fix  [Bug #7996]
  reported and patched by mmeltner (Michael Meltner).
  reported by mitchellh (Mitchell Hashimoto).

Also available in: Atom PDF