From dcf85b88c8f9dd95e1aadcfd0c1dfb83424d6440 Mon Sep 17 00:00:00 2001 From: Krzysztof Gabis Date: Thu, 8 Dec 2016 21:40:52 +0000 Subject: [PATCH] Support for UTF-8 with BOM. Fixes #65 --- parson.c | 3 +++ tests/test_2.txt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/parson.c b/parson.c index e6c2cc6..70fbde4 100644 --- a/parson.c +++ b/parson.c @@ -1004,6 +1004,9 @@ JSON_Value * json_parse_string(const char *string) { if (string == NULL) { return NULL; } + if (string[0] == '\xEF' && string[1] == '\xBB' && string[2] == '\xBF') { + string = string + 3; /* Support for UTF-8 BOM */ + } return parse_value((const char**)&string, 0); } diff --git a/tests/test_2.txt b/tests/test_2.txt index b8c7350..160e7d7 100644 --- a/tests/test_2.txt +++ b/tests/test_2.txt @@ -1,4 +1,4 @@ -{ +{ "string" : "lorem ipsum", "utf string" : "\u006corem\u0020ipsum", "utf-8 string": "あいうえお",