mirror of
https://github.com/rafagafe/tiny-json.git
synced 2025-03-12 19:25:30 +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 ) {
|
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 );
|
json_t const* json = json_create( str, pool, qty );
|
||||||
check( json );
|
check( json );
|
||||||
|
|
||||||
json_t const* a = json_getProperty( json, "a" );
|
json_t const* a = json_getProperty( json, "a" );
|
||||||
check( a );
|
check( a );
|
||||||
check( JSON_TEXT == json_getType( a ) );
|
check( JSON_TEXT == json_getType( a ) );
|
||||||
check( !strcmp( "\tThis text: \"Hello\".\n", json_getValue( 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();
|
done();
|
||||||
}
|
}
|
||||||
|
@ -116,8 +116,8 @@ static char getCharFromUnicode( char const* str ) {
|
|||||||
* @retval Pointer to first non white space after the string. If success.
|
* @retval Pointer to first non white space after the string. If success.
|
||||||
* @retval Null pointer if any error occur. */
|
* @retval Null pointer if any error occur. */
|
||||||
static char* parseString( char* str ) {
|
static char* parseString( char* str ) {
|
||||||
char* head = str;
|
unsigned char* head = (unsigned char*)str;
|
||||||
char* tail = str;
|
unsigned char* tail = (unsigned char*)str;
|
||||||
for( ; *head >= ' '; ++head, ++tail ) {
|
for( ; *head >= ' '; ++head, ++tail ) {
|
||||||
if ( *head == '\"' ) {
|
if ( *head == '\"' ) {
|
||||||
*tail = '\0';
|
*tail = '\0';
|
||||||
|
Loading…
Reference in New Issue
Block a user