From 5eb4d70c5f2f775307063bb16024e7b90cd2995e Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 20 May 2008 13:10:28 +0000 Subject: * 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 --- ext/nkf/nkf.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ext/nkf/nkf.c') 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; } -- cgit v1.2.3