So I came across this code sample which works well for me. I have pasted it here for convenience
std::wstring convert(const std::string& input)
{
try
{
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
return converter.from_bytes(input);
}
catch(std::range_error& e)
{
size_t length = input.length();
std::wstring result;
result.reserve(length);
for(size_t i = 0; i < length; i++)
{
result.push_back(input[i] & 0xFF);
}
return result;
}
}
I am having difficulty understanding this statement
result.push_back(input[i] & 0xFF);
can anyone please explain why each character in the string is being ANDed with 0xFF(11111111) ?
Aucun commentaire:
Enregistrer un commentaire