mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-13 02:12:57 +01:00
Merge pull request #241 from cdunn2001/fix-more-utf8
support UTF-8 (specifically, embedded zeroes) in old Writers
This commit is contained in:
commit
c2b988ee74
@ -317,8 +317,14 @@ void FastWriter::writeValue(const Value& value) {
|
||||
document_ += valueToString(value.asDouble());
|
||||
break;
|
||||
case stringValue:
|
||||
document_ += valueToQuotedString(value.asCString());
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str));
|
||||
break;
|
||||
}
|
||||
case booleanValue:
|
||||
document_ += valueToString(value.asBool());
|
||||
break;
|
||||
@ -382,7 +388,7 @@ void StyledWriter::writeValue(const Value& value) {
|
||||
break;
|
||||
case stringValue:
|
||||
{
|
||||
// Is NULL is possible for value.string_?
|
||||
// Is NULL possible for value.string_?
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
@ -599,8 +605,15 @@ void StyledStreamWriter::writeValue(const Value& value) {
|
||||
pushValue(valueToString(value.asDouble()));
|
||||
break;
|
||||
case stringValue:
|
||||
pushValue(valueToQuotedString(value.asCString()));
|
||||
{
|
||||
// Is NULL possible for value.string_?
|
||||
char const* str;
|
||||
char const* end;
|
||||
bool ok = value.getString(&str, &end);
|
||||
if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
|
||||
else pushValue("");
|
||||
break;
|
||||
}
|
||||
case booleanValue:
|
||||
pushValue(valueToString(value.asBool()));
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user