in Include/json_cpp/details/json_parsing.hpp [707:774]
inline bool JSON_Parser<CharType>::handle_unescape_char(Token &token)
{
token.has_unescape_symbol = true;
// This function converts unescaped character pairs (e.g. "\t") into their ASCII or Unicode representations (e.g. tab sign)
// Also it handles \u + 4 hexadecimal digits
auto ch = NextCharacter();
switch (ch)
{
case '\"':
token.string_val.push_back('\"');
return true;
case '\\':
token.string_val.push_back('\\');
return true;
case '/':
token.string_val.push_back('/');
return true;
case 'b':
token.string_val.push_back('\b');
return true;
case 'f':
token.string_val.push_back('\f');
return true;
case 'r':
token.string_val.push_back('\r');
return true;
case 'n':
token.string_val.push_back('\n');
return true;
case 't':
token.string_val.push_back('\t');
return true;
case 'u':
{
// A four-hexdigit Unicode character.
// Transform into a 16 bit code point.
int decoded = 0;
for (int i = 0; i < 4; ++i)
{
ch = NextCharacter();
int ch_int = static_cast<int>(ch);
if (ch_int < 0 || ch_int > 127)
return false;
#ifdef _WIN32
const int isxdigitResult = _isxdigit_l(ch_int, utility::details::scoped_c_thread_locale::c_locale());
#else
const int isxdigitResult = isxdigit(ch_int);
#endif
if (!isxdigitResult)
return false;
int val = _hexval[static_cast<size_t>(ch_int)];
_ASSERTE(val != -1);
// Add the input char to the decoded number
decoded |= (val << (4 * (3 - i)));
}
// Construct the character based on the decoded number
convert_append_unicode_code_unit(token, static_cast<utf16char>(decoded));
return true;
}
default:
return false;
}
}