1
考慮下面的例子:std :: strtoul等效於C++標準庫嗎?
#include <iostream>
#include <clocale>
#include <cstdlib>
#include <string>
int main()
{
std::setlocale(LC_ALL, "en_US.utf8");
std::string s = "03A0";
wchar_t wstr = std::strtoul(s.c_str(), nullptr, 16);
std::wcout << wstr;
}
此輸出Π
上Coliru。
問題
std::strtoul
,距離<cstdlib>
。我用它完全沒問題,但是我想知道上面的例子是否可能只使用C++標準庫(可能是stringstreams)?
另請注意,字符串上沒有指定十六進制的優先。
啊,啊,我完全忘了那些。它看起來像[MSVC2012](http://msdn.microsoft.com/en-us/library/ee404871.aspx)支持它們,非常棒。 –
@JesseGood,Yup,不過要小心,因爲大多數'to_string'調用都會模糊不清。 – chris