jsonxx icon indicating copy to clipboard operation
jsonxx copied to clipboard

Unicode characters puts nulls into string under Windows

Open bpeikes opened this issue 10 years ago • 3 comments

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.

bpeikes avatar Jul 25 '14 19:07 bpeikes

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.

Rapptz avatar Jul 25 '14 20:07 Rapptz

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.

bpeikes avatar Jul 29 '14 03:07 bpeikes

"\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

r-lyeh-archived avatar Jul 29 '14 07:07 r-lyeh-archived