Skip to content

Commit

Permalink
Added additional JSON escaped characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
allinurl committed Nov 21, 2013
1 parent 87628e0 commit ee4b399
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions output.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,26 @@ escape_json_output (FILE * fp, char *s)
case '"':
fprintf (fp, "\\\"");
break;
case '\'':
fprintf (fp, "\\\'");
break;
case '\\':
fprintf (fp, "\\\\");
break;
//TODO: escape \t \b \r \n and charcters less than U0020 if something breaks it again
//TODO: escape \\x?? to \\u00?? if necessary
/* unusual to be on a log */
case '\b':
fprintf (fp, "\\\b");
break;
case '\f':
fprintf (fp, "\\\f");
break;
case '\n':
fprintf (fp, "\\\n");
break;
case '\r':
fprintf (fp, "\\\r");
break;
case '\t':
fprintf (fp, "\\\t");
break;
/* TODO: escape four-hex-digits, \u */
default:
fputc (*s, fp);
break;
Expand Down

0 comments on commit ee4b399

Please sign in to comment.