iconv
2004-06-17
昨日のエラー調査に関連して、 iconv の挙動を確認。
require 'iconv'
def convtest(*str)
dst = Iconv.iconv('SHIFT-JIS', 'EUC-JP', *str)
puts "str: #{dst.to_s}"
puts " -> #{dst.class}[#{dst.size}]"
end
convtest('This is a pen')
convtest("123\n456")
convtest('abc', 'def')
convtest('あいうえお')
結果は以下の通り。
str: This is a pen
-> Array[1]
str: 123
456
-> Array[1]
str: abcdef
-> Array[2]
str: あいうえお
-> Array[1]
引数の3番目以降が複数ある場合に、返り値の配列も複数になるみたい。 リファレンスマニュアルを見れば、当たり前のことか。