From 1c7b42e2bc7020a216baa69607f98ed0ca745c91 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 7 Oct 2013 06:09:01 +0000 Subject: win32/file.c: check ASCII encodings first * win32/file.c (code_page): check US-ASCII and ASCII-8bit before ordinary mapping. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/file.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'win32/file.c') diff --git a/win32/file.c b/win32/file.c index 407824906a..9647e0ac2d 100644 --- a/win32/file.c +++ b/win32/file.c @@ -186,6 +186,11 @@ code_page(rb_encoding *enc) if (!enc) return system_code_page(); + /* map US-ASCII and ASCII-8bit as code page 1252 (us-ascii) */ + if (enc == rb_usascii_encoding() || enc == rb_ascii8bit_encoding()) { + return 1252; + } + enc_name = (char *)rb_enc_name(enc); fake_str.basic.flags = T_STRING|RSTRING_NOEMBED; @@ -206,16 +211,6 @@ code_page(rb_encoding *enc) if (!NIL_P(encoding)) { CONST_ID(names, "names"); names_ary = rb_funcall(encoding, names, 0); - } - - /* map US-ASCII and ASCII-8bit as code page 1252 (us-ascii) */ - if (enc == rb_usascii_encoding() || enc == rb_ascii8bit_encoding()) { - UINT code_page = 1252; - rb_hash_aset(rb_code_page, name_key, INT2FIX(code_page)); - return code_page; - } - - if (names_ary != Qundef) { for (i = 0; i < RARRAY_LEN(names_ary); i++) { name = RARRAY_PTR(names_ary)[i]; if (strncmp("CP", RSTRING_PTR(name), 2) == 0) { -- cgit v1.2.3