Issue #7005 has been reported by tommy (Masahiro Tomita). ---------------------------------------- Bug #7005: NKF: CP50221 から CP932 に変換できない文字がある https://bugs.ruby-lang.org/issues/7005 Author: tommy (Masahiro Tomita) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux] NKF で CP50221 から CP932 に変換できない文字があります。 CP932 で 0xF040 から 0xF9FC までの文字のうち 589 文字が変換できません。 どうやら CP50221 で1バイト目が 0x80 以上で2バイト目が 0x21-0x3F の文字が変換できないようです。 以下のプログラムは CP932 で 0xF040 から 0xF9FC までの文字を CP50221 に変換して CP932 に戻して、 空文字列になってしまうものを出力してます。 Ruby 1.8.7 では変換できない文字はありませんでした。 require 'nkf' (0xf0..0xf9).each do |c1| (0x40..0xfc).each do |c2| next if c2 == 0x7f cp932 = [c1, c2].pack("C*") cp50221 = NKF.nkf("-m0x --ic=cp932 --oc=cp50221", cp932) cp932_bak = NKF.nkf("-m0x --ic=cp50221 --oc=cp932", cp50221) if cp932_bak.empty? puts [cp932.unpack("H*"), cp50221.unpack("H*")].join(" ") end end end
on 2012-09-11 16:06
on 2012-09-11 16:12
Issue #7005 has been updated by tommy (Masahiro Tomita). Ruby 1.8.7 の ext/nkf を 1.9.3 で無理やりコンパイルしてみたところ問題なかったので NKF のバージョンによるものなのかもしれません。 ---------------------------------------- Bug #7005: NKF: CP50221 から CP932 に変換できない文字がある https://bugs.ruby-lang.org/issues/7005#change-29245 Author: tommy (Masahiro Tomita) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux] NKF で CP50221 から CP932 に変換できない文字があります。 CP932 で 0xF040 から 0xF9FC までの文字のうち 589 文字が変換できません。 どうやら CP50221 で1バイト目が 0x80 以上で2バイト目が 0x21-0x3F の文字が変換できないようです。 以下のプログラムは CP932 で 0xF040 から 0xF9FC までの文字を CP50221 に変換して CP932 に戻して、 空文字列になってしまうものを出力してます。 Ruby 1.8.7 では変換できない文字はありませんでした。 require 'nkf' (0xf0..0xf9).each do |c1| (0x40..0xfc).each do |c2| next if c2 == 0x7f cp932 = [c1, c2].pack("C*") cp50221 = NKF.nkf("-m0x --ic=cp932 --oc=cp50221", cp932) cp932_bak = NKF.nkf("-m0x --ic=cp50221 --oc=cp932", cp50221) if cp932_bak.empty? puts [cp932.unpack("H*"), cp50221.unpack("H*")].join(" ") end end end
on 2012-09-12 16:50
Issue #7005 has been updated by tommy (Masahiro Tomita). NKF の問題だったので NKF のフォーラムに投稿しました。 http://sourceforge.jp/forum/forum.php?thread_id=32... ---------------------------------------- Bug #7005: NKF: CP50221 から CP932 に変換できない文字がある https://bugs.ruby-lang.org/issues/7005#change-29259 Author: tommy (Masahiro Tomita) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux] NKF で CP50221 から CP932 に変換できない文字があります。 CP932 で 0xF040 から 0xF9FC までの文字のうち 589 文字が変換できません。 どうやら CP50221 で1バイト目が 0x80 以上で2バイト目が 0x21-0x3F の文字が変換できないようです。 以下のプログラムは CP932 で 0xF040 から 0xF9FC までの文字を CP50221 に変換して CP932 に戻して、 空文字列になってしまうものを出力してます。 Ruby 1.8.7 では変換できない文字はありませんでした。 require 'nkf' (0xf0..0xf9).each do |c1| (0x40..0xfc).each do |c2| next if c2 == 0x7f cp932 = [c1, c2].pack("C*") cp50221 = NKF.nkf("-m0x --ic=cp932 --oc=cp50221", cp932) cp932_bak = NKF.nkf("-m0x --ic=cp50221 --oc=cp932", cp50221) if cp932_bak.empty? puts [cp932.unpack("H*"), cp50221.unpack("H*")].join(" ") end end end
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.