gpt4 book ai didi

utf-8 - 在 bash 中将转义字符转换为 UTF-8

转载 作者:行者123 更新时间:2023-12-01 09:13:15 25 4
gpt4 key购买 nike

我有一个包含序列的大文本文件,例如

\u02BBUtthay\u0101n h\u01E3ng Ch\u0101t 考艾

但是,它们的呈现方式与上面完全相同。我如何转换它以便人们只看到 UTF-8?如果可能,我更愿意在命令行处理文件。

最佳答案

使用 printf 命令。

http://manpages.ubuntu.com/manpages/intrepid/man3/printf.3.html

如果需要,您也可以将其包装在 $() 中用作变量。

例如,

echo $(printf '\u02BBUtthay\u0101n h\u01E3ng Ch\u0101t Khao Yai')

输出:ʻUtthayān hǣng Chāt Khao Yai

希望对您有所帮助。

关于utf-8 - 在 bash 中将转义字符转换为 UTF-8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19938317/

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