aboutsummaryrefslogtreecommitdiffstats
path: root/qjson.c
diff options
context:
space:
mode:
Diffstat (limited to 'qjson.c')
-rw-r--r--qjson.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/qjson.c b/qjson.c
index 60c904d3f..9ad8a9120 100644
--- a/qjson.c
+++ b/qjson.c
@@ -163,8 +163,14 @@ static void to_json(const QObject *obj, QString *str)
qstring_append(str, "\\t");
break;
default: {
- char buf[2] = { ptr[0], 0 };
- qstring_append(str, buf);
+ if (ptr[0] <= 0x1F) {
+ char escape[7];
+ snprintf(escape, sizeof(escape), "\\u%04X", ptr[0]);
+ qstring_append(str, escape);
+ } else {
+ char buf[2] = { ptr[0], 0 };
+ qstring_append(str, buf);
+ }
break;
}
}