def utf8(string)
begin
- return Iconv::iconv("UTF-8", $CURRENT_CHARSET, string).to_s
+ return Iconv.conv("UTF-8", $CURRENT_CHARSET, string)
rescue
return "???"
end
def utf8cut(string, maxlen)
begin
- return Iconv::iconv("UTF-8", $CURRENT_CHARSET, string[0..maxlen-1]).to_s
+ return Iconv.conv("UTF-8", $CURRENT_CHARSET, string[0..maxlen-1])
rescue Iconv::InvalidCharacter
return utf8cut(string, maxlen-1)
rescue
end
def from_utf8(string)
- return Iconv::iconv($CURRENT_CHARSET, "UTF-8", string).to_s
+ return Iconv.conv($CURRENT_CHARSET, "UTF-8", string)
end
def from_utf8_safe(string)
begin
- return Iconv::iconv($CURRENT_CHARSET, "UTF-8", string).to_s
+ return Iconv.conv($CURRENT_CHARSET, "UTF-8", string)
rescue Iconv::IllegalSequence
return ''
end