gpt4 book ai didi

bash - 计算 UTF-8 文件中的字符

转载 作者:行者123 更新时间:2023-11-29 09:35:34 26 4
gpt4 key购买 nike

wc -c

似乎只做一个愚蠢的字节计数,而不是解释编码方面的实际字符。

我怎样才能得到实际的字符数?

最佳答案

使用-m--chars 选项。

例如(text 文件包含两个韩文字符和换行符):

falsetru@jmlee12:~$ cat text
안녕
falsetru@jmlee12:~$ wc -c text
7 text
falsetru@jmlee12:~$ wc -m text
3 text

根据wc(1):

   -c, --bytes
print the byte counts

-m, --chars
print the character counts

关于bash - 计算 UTF-8 文件中的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19852618/

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