Fixed bug introduced by utf-8 patch with fix provided by Henry Ludemann. All unit tests are now passing.

This commit is contained in:
Baptiste Lepilleur 2009-11-18 17:01:09 +00:00
parent b0ab79bc5b
commit eda47b61b5

View File

@ -120,8 +120,10 @@ std::string valueToQuotedString( const char *value )
std::string result;
result.reserve(maxsize); // to avoid lots of mallocs
result += "\"";
for (const char* c=value; *c != 0; ++c){
switch(*c){
for (const char* c=value; *c != 0; ++c)
{
switch(*c)
{
case '\"':
result += "\\\"";
break;
@ -143,10 +145,14 @@ std::string valueToQuotedString( const char *value )
case '\t':
result += "\\t";
break;
case '/':
//case '/':
// Even though \/ is considered a legal escape in JSON, a bare
// slash is also legal, so I see no reason to escape it.
// (I hope I am not misunderstanding something.)
// (I hope I am not misunderstanding something.
// blep notes: actually escaping \/ may be useful in javascript to avoid </
// sequence.
// Should add a flag to allow this compatibility mode and prevent this
// sequence from occurring.
default:
if ( isControlCharacter( *c ) )
{
@ -155,10 +161,12 @@ std::string valueToQuotedString( const char *value )
result += oss.str();
}
else
{
result += *c;
}
break;
}
}
result += "\"";
return result;
}