レシピブック 019,020,021
Date:2013-12-20 20:12:23 +0900
Categories: TECHNOLOGY
Categories: TECHNOLOGY
コマンドプロンプト上であえてutf-8した
[1] pry(main)> #encoding: utf-8 [2] pry(main)> [3] pry(main)> str = "こんにちわ" => "x82xB1x82xF1x82xC9x82xBFx82xED" [4] pry(main)> str.size => 10 [5] pry(main)> p str.encoding # => # [6] pry(main)> p str "x82xB1x82xF1x82xC9x82xBFx82xED" => "x82xB1x82xF1x82xC9x82xBFx82xED"
こんどはShift_JISする
[1] pry(main)> # encoding: Shift_JIS [2] pry(main)> [3] pry(main)> str = "こんにちわ" => "x82xB1x82xF1x82xC9x82xBFx82xED" [4] pry(main)> p str.encoding # => # [5] pry(main)> p str.size 10 => 10
2.0のせいなのか書いたとおりに書いて同じ結果にならない「」この部分。
次。
[7] pry(main)> p "Hello".encoding # => # [8] pry(main)> p Encoding.list [#, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #, #]
何か配列ですげーかえってきた。なんでーアスキーなのかなー。pryのせいかなー。
NKFの章はダメポ。何かだめなのだろうな。
[1] pry(main)> require 'nkf' => true [2] pry(main)> p NKF.nkf("-s -m0", "x82xB1x82xF1x82xC9x82xBFx82xED") "x{82B1}x{82F1}x{82C9}x{82BF}x{82ED}" => "x{82B1}x{82F1}x{82C9}x{82BF}x{82ED}" [3] pry(main)> p NKF.nkf("-w -m0", "x82xB1x82xF1x82xC9x82xBFx82xED") "u3053u3093u306Bu3061u308F" => "u3053u3093u306Bu3061u308F" [4] pry(main)> p NKF.nkf("-W -m0", "x82xB1x82xF1x82xC9x82xBFx82xED") ArgumentError: no output encoding given from (pry):4:in `nkf' [5] pry(main)> p NKF.nkf("-s -m0", "こんにちわ") "x{82B1}x{82F1}x{82C9}x{82BF}x{82ED}" => "x{82B1}x{82F1}x{82C9}x{82BF}x{82ED}" [6] pry(main)> p NKF.nkf("-w -m0", "こんにちわ") "u3053u3093u306Bu3061u308F" => "u3053u3093u306Bu3061u308F" [7] pry(main)> p NKF.nkf("-e -m0", "こんにちわ") "x{A4B3}x{A4F3}x{A4CB}x{A4C1}x{A4EF}" => "x{A4B3}x{A4F3}x{A4CB}x{A4C1}x{A4EF}" [8] pry(main)> exitTweet