Skip to content

Commit

Permalink
Merge pull request kgabis#5 from 9re/master
Browse files Browse the repository at this point in the history
Allow utf-8 encoded strings.
  • Loading branch information
kgabis committed Feb 7, 2013
2 parents 29595c8 + 155f7f0 commit 9dfee46
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions parson.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ static const char * get_processed_string(const char **string) {
return NULL;
break;
}
} else if (iscntrl((unsigned char)current_char) &&
((unsigned char)current_char != 0x7F)) { /* no control characters allowed (except DEL)*/
} else if ((unsigned char)current_char < 0x20) { /* 0x00-0x19 are invalid characters for json string (http://www.ietf.org/rfc/rfc4627.txt) */
parson_free(output);
return NULL;
}
Expand Down
1 change: 1 addition & 0 deletions tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ void test_suite_2(void) {
object = json_value_get_object(root_value);
TEST(STREQ(json_object_get_string(object, "string"), "lorem ipsum"));
TEST(STREQ(json_object_get_string(object, "utf string"), "lorem ipsum"));
TEST(STREQ(json_object_get_string(object, "utf-8 string"), "あいうえお"));
TEST(json_object_get_number(object, "positive one") == 1.0);
TEST(json_object_get_number(object, "negative one") == -1.0);
TEST(json_object_get_number(object, "hard to parse number") == -0.000314);
Expand Down
1 change: 1 addition & 0 deletions tests/test_2.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"string" : "lorem ipsum",
"utf string" : "\u006corem\u0020ipsum",
"utf-8 string": "あいうえお",
"positive one" : 1,
"negative one" : -1,
"pi" : 3.14,
Expand Down

0 comments on commit 9dfee46

Please sign in to comment.