我正在尝试将此代码转换为 unicode
int fromHex(const supportlib::string_t &s)
{
return std::strtoul(s.c_str(), NULL, 16);
}
supportlib::string_t
类型定义为 std::string
或 std::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/