计算UTF-8文件中的字符

use*_*725 2 unix bash encoding utf-8 wc

wc -c
Run Code Online (Sandbox Code Playgroud)

似乎只做一个愚蠢的字节数,而不是解释关于编码的实际字符.

如何获得实际字符数?

fal*_*tru 8

使用-m--chars选项.

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

falsetru@jmlee12:~$ cat text
??
falsetru@jmlee12:~$ wc -c text
7 text
falsetru@jmlee12:~$ wc -m text
3 text
Run Code Online (Sandbox Code Playgroud)

根据wc(1):

   -c, --bytes
          print the byte counts

   -m, --chars
          print the character counts
Run Code Online (Sandbox Code Playgroud)