I have the following code:
#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;
}
The problem is that the method converter.from_bytes
throws an exception. Why? How should I parse the given string?
The exception is of type std::range_error
with the message
bad conversion
The problem is related to the character '°', since if I remove this character the conversion works fine.