Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Linux 上的宽字符是否有 ac atoi() 等效项?我可以为 MS (wtoi) 找到一些东西,但我可以在标准 Linux 库中找到任何东西。
您可以使用wcstol将宽字符串转换为整数值。
Linux 程序使用wchar_t类型是不寻常的。
wchar_t
原因是 Linux 使用 utf-8 作为标准编码。char const*字符串被 glibc 假定为 utf-8 字符串。Ascii 数字和 utf-8 数字具有相同的字节表示,因此 atoi() 对 ascii 和 utf-8 字符串都有效。
char const*
话虽如此,看看#include <wchar.t>,它提供了wcstol().
#include <wchar.t>
wcstol()