mirror of
https://github.com/kgabis/parson.git
synced 2024-11-24 06:05:29 +00:00
Merge pull request #52 from t-k-/escape
Further escape \x00 - \x1F control characters.
This commit is contained in:
commit
642f0cb4f5
32
parson.c
32
parson.c
@ -911,6 +911,38 @@ static int json_serialize_string(const char *string, char *buf) {
|
||||
case '\n': APPEND_STRING("\\n"); break;
|
||||
case '\r': APPEND_STRING("\\r"); break;
|
||||
case '\t': APPEND_STRING("\\t"); break;
|
||||
case '\x00': APPEND_STRING("\\u0000"); break;
|
||||
case '\x01': APPEND_STRING("\\u0001"); break;
|
||||
case '\x02': APPEND_STRING("\\u0002"); break;
|
||||
case '\x03': APPEND_STRING("\\u0003"); break;
|
||||
case '\x04': APPEND_STRING("\\u0004"); break;
|
||||
case '\x05': APPEND_STRING("\\u0005"); break;
|
||||
case '\x06': APPEND_STRING("\\u0006"); break;
|
||||
case '\x07': APPEND_STRING("\\u0007"); break;
|
||||
/* '\x08' duplicate: '\b' */
|
||||
/* '\x09' duplicate: '\t' */
|
||||
/* '\x0a' duplicate: '\n' */
|
||||
case '\x0b': APPEND_STRING("\\u000b"); break;
|
||||
/* '\x0c' duplicate: '\f' */
|
||||
/* '\x0d' duplicate: '\r' */
|
||||
case '\x0e': APPEND_STRING("\\u000e"); break;
|
||||
case '\x0f': APPEND_STRING("\\u000f"); break;
|
||||
case '\x10': APPEND_STRING("\\u0010"); break;
|
||||
case '\x11': APPEND_STRING("\\u0011"); break;
|
||||
case '\x12': APPEND_STRING("\\u0012"); break;
|
||||
case '\x13': APPEND_STRING("\\u0013"); break;
|
||||
case '\x14': APPEND_STRING("\\u0014"); break;
|
||||
case '\x15': APPEND_STRING("\\u0015"); break;
|
||||
case '\x16': APPEND_STRING("\\u0016"); break;
|
||||
case '\x17': APPEND_STRING("\\u0017"); break;
|
||||
case '\x18': APPEND_STRING("\\u0018"); break;
|
||||
case '\x19': APPEND_STRING("\\u0019"); break;
|
||||
case '\x1a': APPEND_STRING("\\u001a"); break;
|
||||
case '\x1b': APPEND_STRING("\\u001b"); break;
|
||||
case '\x1c': APPEND_STRING("\\u001c"); break;
|
||||
case '\x1d': APPEND_STRING("\\u001d"); break;
|
||||
case '\x1e': APPEND_STRING("\\u001e"); break;
|
||||
case '\x1f': APPEND_STRING("\\u001f"); break;
|
||||
default:
|
||||
if (buf != NULL) {
|
||||
buf[0] = c;
|
||||
|
Loading…
Reference in New Issue
Block a user