summaryrefslogtreecommitdiffstats
path: root/src/bencoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bencoding.c')
-rw-r--r--src/bencoding.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bencoding.c b/src/bencoding.c
index b32e2ea..e456486 100644
--- a/src/bencoding.c
+++ b/src/bencoding.c
@@ -197,12 +197,16 @@ int b2json_charsize (unsigned char a) {
return 2;
if (a < ' ')
return 6;
+ if (a > 127)
+ return 1;
return 1;
}
/**
* write a string representation of a character in a JSON string
*
+ * non-ASCII characters are replaced with a '.'
+ *
* @param dest [out] destination
* @param a [in] the character in question
* @return the destination pointer, incremented for the number of bytes written
@@ -239,6 +243,9 @@ char * b2json_charrepr (char * dest, unsigned char a) {
sprintf(buf, "\\u00%02x", a);
strncpy(dest, buf, 6);
return dest+6;
+ } else if (a > 127) {
+ *dest++ = '.';
+ return dest;
} else {
*dest++ = a;
return dest;