jsonxx
jsonxx copied to clipboard
Unicode characters puts nulls into string under Windows
It looks like there is an issue when using this under Windows and there are unicode characters. The code in parse_string does not appear to work. It might be due to the implementation of stringstream.
In the code for parse_string, there is the following code:
case 'u': int i; std::stringstream ss; for( i = 0; (!input.eof() && input.good()) && i < 4; ++i ) { input.get(ch); ss << ch; } if( input.good() && (ss >> i) ) value.push_back(i);
Using Visual Studio 2013, ss >> i, on the stream "000d" makes i == 0, which means that there are embedded nuls. I'm not even sure what (ss >> i) is supposed to return when cast to a bool.
ss >> i
is supposed to return the state of the stream. Not the extracted character. So ss >> i
should return true
regardless of whether or not there are embedded nulls.
I'm not sure what the issue is then. I'll have to double check. The issue I'm having is that when I step through the code I'm getting nulls added to value.
"\u000d" should parse integer to 0x0d according other utf-8 escaped tests. we could add this case to the escaped utf-8 tests and ensure it is not broken at the moment