aboutsummaryrefslogtreecommitdiff
path: root/src/unstable/json.cpp
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2018-12-17 10:03:18 -0800
committerMike Buland <mbuland@penny-arcade.com>2018-12-17 10:03:18 -0800
commit4a541f7ba5306f9ebcc7f0fe2eeb663d3f527070 (patch)
tree4402b7d6c711fe79d30d33981a188d99d2c2c81b /src/unstable/json.cpp
parent3f67108249b5c4f97841beee18fdd761919fe754 (diff)
downloadlibbu++-4a541f7ba5306f9ebcc7f0fe2eeb663d3f527070.tar.gz
libbu++-4a541f7ba5306f9ebcc7f0fe2eeb663d3f527070.tar.bz2
libbu++-4a541f7ba5306f9ebcc7f0fe2eeb663d3f527070.tar.xz
libbu++-4a541f7ba5306f9ebcc7f0fe2eeb663d3f527070.zip
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.
Diffstat (limited to 'src/unstable/json.cpp')
-rw-r--r--src/unstable/json.cpp11
1 files changed, 10 insertions, 1 deletions
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
747 break; 747 break;
748 748
749 default: 749 default:
750 sOutput.write( &(*i), 1 ); 750 if( *i < 32 )
751 sOutput.write(
752 Bu::String("\\u%1").
753 arg( (int32_t)*i, Bu::Fmt::hex(4).fill('0') ).
754 end().getStr(),
755 6
756 );
757 else
758 sOutput.write( &(*i), 1 );
759 break;
751 } 760 }
752 } 761 }
753 sOutput.write("\"", 1 ); 762 sOutput.write("\"", 1 );