Changeset e8161ec for lib


Ignore:
Timestamp:
2012-12-01T12:13:44Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
3ca001b
Parents:
85cd12d
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/json.c

    r85cd12d re8161ec  
    4343#endif
    4444
     45#include <glib.h>
    4546#include <stdlib.h>
    4647#include <stdio.h>
     
    287288                           string_length += 2;
    288289                        else
    289                         {  string [string_length ++] = 0xC0 | ((uc_b2 & 0xC0) >> 6) | ((uc_b1 & 0x3) << 3);
     290                        {  string [string_length ++] = 0xC0 | ((uc_b2 & 0xC0) >> 6) | ((uc_b1 & 0x7) << 2);
    290291                           string [string_length ++] = 0x80 | (uc_b2 & 0x3F);
    291292                        }
     
    483484
    484485                           if (top->type == json_double)
    485                               top->u.dbl = strtod (i, (json_char **) &i);
     486                              top->u.dbl = g_ascii_strtod (i, (json_char **) &i);
    486487                           else
    487                               top->u.integer = strtoll (i, (json_char **) &i, 10);
     488                              top->u.integer = g_ascii_strtoll (i, (json_char **) &i, 10);
    488489
    489490                           flags |= flag_next | flag_reproc;
Note: See TracChangeset for help on using the changeset viewer.