那就比如,某文本文件是utf-16的编码,我该如何读取呢? ruby下输入了个File.public_methods……瞬间晕了,没找到
回复
str = ''
open("filename") { |fin|
str = fin.read
}
WideCharToMultiByte.call(...) # 把 str 从 UTF-16 转码到 UTF-8
紫苏 发表于 2010-8-8 16:00
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |