summaryrefslogtreecommitdiff
path: root/ext/nkf/nkf.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-20 13:10:28 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-20 13:10:28 +0000
commit5eb4d70c5f2f775307063bb16024e7b90cd2995e (patch)
tree72c2696d4e85f11eee15317d97442b284d323f4f /ext/nkf/nkf.c
parent8405033139bc3ee4cbdf1b1c415910f7df38ebfd (diff)
* ext/nkf/nkf-utf8/nkf.c (rb_nkf_convert) (nkf_enc_without_bom):
reverted. nkf-utf8/nkf.c should be independent of ruby. * ext/nkf/nkf.c (options): moved from nkf-utf8/nkf.c. override nkf's original settings for Unicode BOM. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/nkf/nkf.c')
-rw-r--r--ext/nkf/nkf.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index eb7d76af14..c64605b382 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -143,6 +143,15 @@ rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
nkf_split_options(RSTRING_PTR(opt));
if (!output_encoding) rb_raise(rb_eArgError, "no output encoding given");
+ switch (nkf_enc_to_index(output_encoding)) {
+ case UTF_8_BOM: output_encoding = nkf_enc_from_index(UTF_8); break;
+ case UTF_16BE_BOM: output_encoding = nkf_enc_from_index(UTF_16BE); break;
+ case UTF_16LE_BOM: output_encoding = nkf_enc_from_index(UTF_16LE); break;
+ case UTF_32BE_BOM: output_encoding = nkf_enc_from_index(UTF_32BE); break;
+ case UTF_32LE_BOM: output_encoding = nkf_enc_from_index(UTF_32LE); break;
+ }
+ output_bom_f = FALSE;
+
incsize = INCSIZE;
input_ctr = 0;
@@ -160,7 +169,7 @@ rb_nkf_convert(VALUE obj, VALUE opt, VALUE src)
rb_str_set_len(result, output_ctr);
OBJ_INFECT(result, src);
- rb_enc_associate(result, rb_nkf_enc_get(nkf_enc_name(nkf_enc_without_bom(output_encoding))));
+ rb_enc_associate(result, rb_nkf_enc_get(nkf_enc_name(output_encoding)));
return result;
}