diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-20 04:20:53 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-20 04:20:53 +0000 |
commit | 7992fabaf40f8635653d267592f591d9cc4c511e (patch) | |
tree | fd906fc8dd233306c3b07515726ee374eb35881d /ext/nkf/nkf-utf8/nkf.c | |
parent | 75aa81b79d078ba7d02e097cf53e629d851d874c (diff) | |
download | ruby-7992fabaf40f8635653d267592f591d9cc4c511e.tar.gz |
* ext/nkf/nkf.c (rb_nkf_convert), ext/nkf/nkf-utf8/nkf.c
(nkf_enc_without_bom): BOM is not a part of encodings.
* ext/nkf/nkf.c (Init_nkf), ext/nkf/nkf-utf8/nkf.c (options):
UTF-{16,32} without endian have no sense.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/nkf/nkf-utf8/nkf.c')
-rw-r--r-- | ext/nkf/nkf-utf8/nkf.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/ext/nkf/nkf-utf8/nkf.c b/ext/nkf/nkf-utf8/nkf.c index 523462362b..df062e0a35 100644 --- a/ext/nkf/nkf-utf8/nkf.c +++ b/ext/nkf/nkf-utf8/nkf.c @@ -693,6 +693,20 @@ static int nkf_enc_find_index(const char *name) return index; } +static nkf_encoding *nkf_enc_without_bom(nkf_encoding *enc) +{ + int idx; + switch (enc->id) { + case UTF_8_BOM: idx = UTF_8; break; + case UTF_16BE_BOM: idx = UTF_16BE; break; + case UTF_16LE_BOM: idx = UTF_16LE; break; + case UTF_32BE_BOM: idx = UTF_32BE; break; + case UTF_32LE_BOM: idx = UTF_32LE; break; + default: return enc; + } + return &nkf_encoding_table[idx]; +} + static nkf_encoding *nkf_enc_find(const char *name) { int idx = -1; @@ -5897,8 +5911,7 @@ void options(unsigned char *cp) } else if (cp[0] == 'B') { cp++; } else { - output_encoding = nkf_enc_from_index(enc_idx); - continue; + goto utf_no_endian; } if (cp[0] == '0'){ cp++; @@ -5907,6 +5920,7 @@ void options(unsigned char *cp) : (output_endian == ENDIAN_LITTLE ? UTF_32LE : UTF_32BE); } else { output_bom_f = TRUE; + utf_no_endian: enc_idx = enc_idx == UTF_16 ? (output_endian == ENDIAN_LITTLE ? UTF_16LE_BOM : UTF_16BE_BOM) : (output_endian == ENDIAN_LITTLE ? UTF_32LE_BOM : UTF_32BE_BOM); |