diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-07 06:09:01 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-07 06:09:01 +0000 |
commit | 1c7b42e2bc7020a216baa69607f98ed0ca745c91 (patch) | |
tree | 257d03471001c5d836a24172b9ab35fa1fd00b9a /win32/file.c | |
parent | 1ccaef99387466be96e2fe89f02d55e074bea227 (diff) |
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
Diffstat (limited to 'win32/file.c')
-rw-r--r-- | win32/file.c | 15 |
1 files changed, 5 insertions, 10 deletions
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) { |