kconv(str, out_code, in_code = AUTO)
public
Convert str to out_code. out_code and in_code are given as constants of Kconv.
Note This method decode MIME encoded string and convert halfwidth
katakana to fullwidth katakana. If you don’t want to decode them, use
NKF.nkf.
Show source
def kconv(str, out_code, in_code = AUTO)
opt = '-'
case in_code
when ::NKF::JIS
opt << 'J'
when ::NKF::EUC
opt << 'E'
when ::NKF::SJIS
opt << 'S'
when ::NKF::UTF8
opt << 'W'
when ::NKF::UTF16
opt << 'W16'
end
case out_code
when ::NKF::JIS
opt << 'j'
when ::NKF::EUC
opt << 'e'
when ::NKF::SJIS
opt << 's'
when ::NKF::UTF8
opt << 'w'
when ::NKF::UTF16
opt << 'w16'
when ::NKF::NOCONV
return str
end
opt = '' if opt == '-'
::NKF::nkf(opt, str)
end