c++ - 什么是 std::strtoul for unicode

标签 c++ unicode

我正在尝试将此代码转换为 unicode

int fromHex(const supportlib::string_t &s)
{
    return std::strtoul(s.c_str(), NULL, 16);
}

supportlib::string_t 类型定义为 std::stringstd::wstring 取决于我是想用 unicode 编译还是ASCII.

对于大多数其他类型,我可以找到一个宽版本,但不是用于 std::strtoul 那么我应该使用什么来代替? std::wstrtoul 与大多数其他类型不同。

我正在使用 MingW 和 gcc 4.8.1。

当我在 unicode 模式下编译它时,我得到这个错误:

error: cannot convert 'const wchar_t*' to 'const char*' for argument '1' to 'long unsigned int strtoul(const char*, char**, int)'

最佳答案

至少在 C99 中,它位于 wchar.h 中,原型(prototype)如下:

unsigned long int wcstoul ( const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);

关于c++ - 什么是 std::strtoul for unicode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21439283/

相关文章:

c# - 在 C# 字符串/字符编码中,GetBytes()、GetString() 和 Convert() 之间有什么区别?

c# - C# 中的 CodePointAt 等价物

c++ - 如何将打印从屏幕(或任何 FILE*)重定向到 C++ 中的字符串/字符*

c++ - wstring -> ShellExecute 中的 LPCWSTR 给我错误 LNK2028 和 LNK2019

c++ - [[maybe_unused]] 和构造函数

cocoa - 如何将 NSString 转换为 NSData?

unicode - 'missing glyph' 框的代码点

c++ - 32 位逆向工程加密功能失败 64 位

c++ - Visual Studio 2010 链接库并包含多个项目的路径

mysql unicode 文本插入时出现不正确的字符串警告,尽管字符集变量设置为 utf8mb4