在构建一个读取命令输出的工具时,我意识到一些 Linux 实用程序会输出 Unicode 字符,而我真的没想到它们会这样做。例如,在其错误输出中find
使用‘
(而不是 ASCII '
)作为引号字符:
~ > find /root
/root
find: ‘/root’: Permission denied
Run Code Online (Sandbox Code Playgroud)
这同样适用于g++
:
main.cpp: In function ‘int main()’:
main.cpp:2:9: error: ‘foo’ was not declared in this scope
return foo;
^~~
main.cpp:2:9: note: suggested alternative: ‘bool’
return foo;
^~~
bool
Run Code Online (Sandbox Code Playgroud)
这与我的系统区域设置有关吗?或者这是别的什么?的输出localectl
:
System Locale: LANG=en_ZA.UTF-8
LANGUAGE=en_ZA:en
VC Keymap: n/a
X11 Layout: us
X11 Model: pc105
Run Code Online (Sandbox Code Playgroud)