diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2012-12-01 12:13:44 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2012-12-01 12:13:44 +0000 |
commit | e8161ec5bf893d935148fe48925d1315f3aab949 (patch) | |
tree | 0e99a96b969eeeeb67e3a2a4af4c5b98a7937d43 /lib/json.c | |
parent | 85cd12daeea9dd537566735ee426974a19533337 (diff) |
Importing json.c UTF-8 encoding fix from upstream. Not importing the
strto(d|l) fix because I can just use GLib instead of reinventing the wheel.
This should fix corruption issues with tweets in Cyrillic. I've double-
checked this code against http://en.wikipedia.org/wiki/UTF-8 now and it looks
correct to me.
Diffstat (limited to 'lib/json.c')
-rw-r--r-- | lib/json.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -42,6 +42,7 @@ const struct _json_value json_value_none = { 0 }; #endif +#include <glib.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -286,7 +287,7 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch if (state.first_pass) string_length += 2; else - { string [string_length ++] = 0xC0 | ((uc_b2 & 0xC0) >> 6) | ((uc_b1 & 0x3) << 3); + { string [string_length ++] = 0xC0 | ((uc_b2 & 0xC0) >> 6) | ((uc_b1 & 0x7) << 2); string [string_length ++] = 0x80 | (uc_b2 & 0x3F); } @@ -482,9 +483,9 @@ json_value * json_parse_ex (json_settings * settings, const json_char * json, ch continue; if (top->type == json_double) - top->u.dbl = strtod (i, (json_char **) &i); + top->u.dbl = g_ascii_strtod (i, (json_char **) &i); else - top->u.integer = strtoll (i, (json_char **) &i, 10); + top->u.integer = g_ascii_strtoll (i, (json_char **) &i, 10); flags |= flag_next | flag_reproc; } |