summaryrefslogtreecommitdiff
path: root/win32/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-07 06:50:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-07 06:50:18 +0000
commit98e4a412e468b9c674e2722bf5907470ba54c60c (patch)
tree26d9f65be0eed5c146bd7631559866dc2f20b8d4 /win32/file.c
parent5df9f0d8391938ba3a831a4820f80dea20974ad4 (diff)
win32/file.c: use encoding index
* win32/file.c (code_page): use encoding index, which is primary entity, instead of encoding name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/file.c')
-rw-r--r--win32/file.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/win32/file.c b/win32/file.c
index 678f39673f2..065555a73f0 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -176,7 +176,8 @@ system_code_page(void)
static UINT
code_page(rb_encoding *enc)
{
- st_data_t enc_name, code_page_value;
+ int enc_idx;
+ st_data_t code_page_value;
VALUE encoding, names_ary = Qundef, name;
ID names;
long i;
@@ -184,19 +185,19 @@ code_page(rb_encoding *enc)
if (!enc)
return system_code_page();
+ enc_idx = rb_enc_to_index(enc);
+
/* map US-ASCII and ASCII-8bit as code page 1252 (us-ascii) */
- if (enc == rb_usascii_encoding() || enc == rb_ascii8bit_encoding()) {
+ if (enc_idx == rb_usascii_encindex() || enc_idx == rb_ascii8bit_encindex()) {
return 1252;
}
- enc_name = (st_data_t)rb_enc_name(enc);
-
if (rb_code_page) {
- if (st_lookup(rb_code_page, enc_name, &code_page_value))
+ if (st_lookup(rb_code_page, enc_idx, &code_page_value))
return (UINT)code_page_value;
}
else {
- rb_code_page = st_init_strcasetable();
+ rb_code_page = st_init_numtable();
}
code_page_value = INVALID_CODE_PAGE;
@@ -216,7 +217,7 @@ code_page(rb_encoding *enc)
}
}
- st_insert(rb_code_page, enc_name, code_page_value);
+ st_insert(rb_code_page, enc_idx, code_page_value);
return (UINT)code_page_value;
}