gpt4 book ai didi

command-line - 从 XXX 到 utf-8 的字符集转换,命令行

转载 作者:行者123 更新时间:2023-12-03 21:06:57 24 4
gpt4 key购买 nike

我有一堆以 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 .
  • 上面的例子使用了 shell 重定向。确保您没有使用在重定向时破坏编码的 shell ——也就是说,不要为此使用 PowerShell。
  • 关于command-line - 从 XXX 到 utf-8 的字符集转换,命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2722477/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com