ãã --cp932 ã®æ¬æ¥ã®åããç¥ããªãã®ã§ãããããã¨ããããèªåã®æå¾ éãã§ã¯ãªãã¨ããã¹ãããããã¾ããã
æåã³ã¼ãã®å¤æã®éãJIS è¦æ ¼ãããªã㦠Windows ããã£ã¦ãããããªå¤æããã¦æ¬²ããã¨ãã«ã--cp932 ãã¤ãã¨ãã°è¯ãã«ã¯ããã£ã¦ãããããããªãããªãâ¦ã¨æ¼ ç¶ã¨æã£ã¦ããã®ã§ãã
UTF-8 ãã ISO-2022-JP ã¸ã®å¤æã®å ´åãã-Wj --cp932ãã¨ãã¦ããã°ããã¨æã£ã¦ãããã¾ãããã¾ããã梯åé«ãå¤æãã¦ã¿ã¾ãã
$ ruby -rnkf -e 'puts NKF.nkf("-Wj --cp932", "\xe9\xab\x99").unpack("H*")' 1b242844747b1b2842
ã1b24427c621b2842ããæå¾ ããã®ã§ããã1b242844747b1b2842ãã«ãªã£ã¦ãã¾ãã¾ãããããããã¢ã¬ãªã®ã§è¦ããããã¦ã¿ã¾ãã
æå¾ | ESC $ B 7c 62 ESC ( B |
çµæ | ESC $ ( D 74 7b ESC ( B |
ãESC $ Bã㯠ISO-2022-JP ã® JIS X 0208ããESC $ ( Dã㯠ISO-2022-JP-1 ã® JIS X 0212 ã§ãããã¨ãæå³ãã¦ã¾ãã*1ãªãã--cp932 ãå¤ãã¦ãåãã§ããã
ããããããã ã£ããâ¦ã¨æã£ãã®ã§ããããªã㨠nkf ã³ãã³ãã使ã£ã¦ã¿ããæå¾ éãã«åããã®ã§ãã
$ printf "\xe9\xab\x99\n" | nkf -Wj --cp932 | od -tx1 0000000 1b 24 42 7c 62 1b 28 42 0a 0000011
ã¡ãªã¿ã« --cp932 ãå¤ãã¦ããã¯ãåãã§ããã
$ printf "\xe9\xab\x99\n" | nkf -Wj | od -tx1 0000000 1b 24 42 7c 62 1b 28 42 0a 0000011
ruby 㨠nkf ã³ãã³ãã§åããéãã®ã¯ nkf ã®ãã¼ã¸ã§ã³ãéãããã§ãããã¨ãçããã¾ããã³ãã³ãã©ã¤ã³ã® nkf 㯠2.0.7 ã ã£ãã®ã«å¯¾ããruby ã® nkf 㯠2.0.8 ã§ããã
http://sourceforge.jp/projects/nkf/releases/?package_id=533 ãã nkf ã®è²ã ãªãã¼ã¸ã§ã³ããã¦ã³ãã¼ããã¦ãªãã·ã§ã³ã試ãã¦ã¿ã¾ããã
ãã¼ã¸ã§ã³ | -Wj | -Wj --cp932 | -Wj --no-cp932 | -W --oc=CP50220 | -W --oc=CP50220 --cp932 |
2.0.7 | â | â | Ã | â | â |
2.0.8 | Ã | Ã | â | â | Ã |
2.0.9 | Ã | Ã | â | â | Ã |
ï¼â: JIS X 0208, Ã: JIS X 0212ï¼
2.0.7 㨠2.0.8 以éã¨ã§åããå¤ãã£ã¦ãã¾ãã--cp932 ãªãã·ã§ã³ãæªããã§ãã--cp932 㨠--no-cp932 ã®åããè¦ãã¨ãæå³ãéã«ãªã£ã¦ããããã«ãè¦ãã¾ãã
ãã¹ã¦ã®ãã¼ã¸ã§ã³ã§æå¾ éããªã®ã¯ --oc=CP50220 ãªãã·ã§ã³ãªã®ã§ãããã§è¡ããã¨æãã¾ãã
ãã¨ã§ã梯åé«ä»¥å¤ã試ãã¦ã¿ããã¨æãã¾ãã
*1:ãã¡ããã梯åé«ã¯ JIS ã«ãªãæåã§ãããã¨ã¯æ¿ç¥ãã¦ããã®ã§ãããJIS X 0212 ã«ãªããã§ãâ¦ã