我有以下代碼時:wstring_converter異常解析的c串
#include <iostream>
#include <string>
#include <locale>
#include <codecvt>
using namespace std;
int main()
{
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
const char val[] = "+3°C";
wstring text = converter.from_bytes(val);
return 0;
}
的問題是,該方法converter.from_bytes
拋出異常。爲什麼?我應該如何解析給定的字符串?
唯一的例外是std::range_error
類型的與該消息
壞轉換
因爲如果刪除該字符的問題是關係到字符「°」,則轉換工作正常。
什麼異常?你爲什麼不告訴我們? :( –
[對我的作品(http://coliru.stacked-crooked.com/a/23923c288ed5f9f3)。 –
@LightnessRacesinOrbit它不適合我的工作,請看到我的編輯。我使用Visual Studio 2013年 – Nick