我有一堆以 ISO-8851-2 编码的文本文件(有一些波兰语字符)。是否有用于 linux/mac 的命令行工具,我可以从 shell 脚本运行以将其转换为更清晰的 utf-8?
最佳答案
使用 iconv
,例如像这样:
iconv -f LATIN1 -t UTF-8 input.txt > output.txt
更多信息:
UTF-8//TRANSLIT
而不是普通 UTF-8
.引用联机帮助页:If the string
//TRANSLIT
is appended to to-encoding, characters being converted are transliterated when needed and possible. This means that when a character cannot be represented in the target character set, it can be approximated through one or several similar looking characters. Characters that are outside of the target character set and cannot be transliterated are replaced with a question mark (?) in the output.
iconv
接受的编码代码的完整列表,执行 iconv -l
. 关于command-line - 从 XXX 到 utf-8 的字符集转换,命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2722477/