开发者

c atoi() for wide chars on linux?

开发者 https://www.devze.com 2023-02-12 04:36 出处:网络
Is there a c atoi() equivalent for wide chars on Linu开发者_C百科x? I can find something for MS (wtoi) but I can find anything in a standard Linux lib.You can use wcstol to convert from wide strings t

Is there a c atoi() equivalent for wide chars on Linu开发者_C百科x? I can find something for MS (wtoi) but I can find anything in a standard Linux lib.


You can use wcstol to convert from wide strings to integer values.


It is unusual for a Linux program to use wchar_t type.

The reason being that Linux uses utf-8 as the standard encoding. char const* strings are assumed to be utf-8 strings by glibc. Ascii digits and utf-8 digits have the same byte representation, so that atoi() works both on ascii and utf-8 strings.

Having said that, look in #include <wchar.t>, it provides wcstol().

0

精彩评论

暂无评论...
验证码 换一张
取 消