mirror of
https://github.com/rafagafe/tiny-json.git
synced 2025-03-12 11:25:29 +00:00
Fix non-english characters
This commit is contained in:
parent
b1d8a0cbd6
commit
5381e5027b
36
tests.c
36
tests.c
@ -134,19 +134,37 @@ static int primitive( void ) {
|
||||
}
|
||||
|
||||
static int text( void ) {
|
||||
json_t pool[2];
|
||||
unsigned const qty = sizeof pool / sizeof *pool;
|
||||
|
||||
{
|
||||
json_t pool[2];
|
||||
unsigned const qty = sizeof pool / sizeof *pool;
|
||||
|
||||
char str[] = "{\"a\":\"\\tThis text: \\\"Hello\\\".\\n\"}";
|
||||
char str[] = "{\"a\":\"\\tThis text: \\\"Hello\\\".\\n\"}";
|
||||
|
||||
json_t const* json = json_create( str, pool, qty );
|
||||
check( json );
|
||||
json_t const* json = json_create( str, pool, qty );
|
||||
check( json );
|
||||
|
||||
json_t const* a = json_getProperty( json, "a" );
|
||||
check( a );
|
||||
check( JSON_TEXT == json_getType( a ) );
|
||||
check( !strcmp( "\tThis text: \"Hello\".\n", json_getValue( a ) ) );
|
||||
json_t const* a = json_getProperty( json, "a" );
|
||||
check( a );
|
||||
check( JSON_TEXT == json_getType( a ) );
|
||||
check( !strcmp( "\tThis text: \"Hello\".\n", json_getValue( a ) ) );
|
||||
}
|
||||
|
||||
{
|
||||
json_t pool[2];
|
||||
unsigned const qty = sizeof pool / sizeof *pool;
|
||||
|
||||
char str[] = "{\"name\":\"Christiane Eluère\"}";
|
||||
|
||||
json_t const* json = json_create( str, pool, qty );
|
||||
check( json );
|
||||
|
||||
json_t const* name = json_getProperty( json, "name" );
|
||||
check( name );
|
||||
check( JSON_TEXT == json_getType( name ) );
|
||||
check( !strcmp( "Christiane Eluère", json_getValue( name ) ) );
|
||||
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
|
@ -116,8 +116,8 @@ static char getCharFromUnicode( char const* str ) {
|
||||
* @retval Pointer to first non white space after the string. If success.
|
||||
* @retval Null pointer if any error occur. */
|
||||
static char* parseString( char* str ) {
|
||||
char* head = str;
|
||||
char* tail = str;
|
||||
unsigned char* head = (unsigned char*)str;
|
||||
unsigned char* tail = (unsigned char*)str;
|
||||
for( ; *head >= ' '; ++head, ++tail ) {
|
||||
if ( *head == '\"' ) {
|
||||
*tail = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user