From 4a541f7ba5306f9ebcc7f0fe2eeb663d3f527070 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 17 Dec 2018 10:03:18 -0800 Subject: Bu::Json handles encoding control chars. It still needs to handle the rest of unicode properly. It'll require a minor change but shouldn't be too bad overall. --- src/unstable/json.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/unstable/json.cpp') diff --git a/src/unstable/json.cpp b/src/unstable/json.cpp index adc2706..06df9b1 100644 --- a/src/unstable/json.cpp +++ b/src/unstable/json.cpp @@ -747,7 +747,16 @@ void Bu::Json::writeStr( const Bu::String &sStr, Bu::Stream &sOutput ) const break; default: - sOutput.write( &(*i), 1 ); + if( *i < 32 ) + sOutput.write( + Bu::String("\\u%1"). + arg( (int32_t)*i, Bu::Fmt::hex(4).fill('0') ). + end().getStr(), + 6 + ); + else + sOutput.write( &(*i), 1 ); + break; } } sOutput.write("\"", 1 ); -- cgit v1.2.3