stephenberry / glaze

Extremely fast, in memory, JSON and interface library for modern C++
MIT License
1.07k stars 109 forks source link

`validate_json` returns `syntax_error` if buffer contains non-ASCII chars #977

Closed Chaoses-Ib closed 3 months ago

Chaoses-Ib commented 3 months ago

Example:

// In ANSI (GBK) encoding
auto e = glz::validate_json(R"({"key":"value中文"})");

// In UTF-8
auto e = glz::validate_json((const char*)u8R"({"key":"value中文"})");

image

image

According to RFC 8259, "JSON text exchanged between systems that are not part of a closed ecosystem MUST be encoded using UTF-8". I think at least buffers in UTF-8 encoding should be accepted.

Version: 2.6.0

stephenberry commented 3 months ago

Thanks so much for reporting this. Will plan to fix soon.

stephenberry commented 3 months ago

Thanks again for reporting this. I've merged a fix (#979). I wasn't taking the sign-ness of char into account in some places.

Chaoses-Ib commented 3 months ago

Thanks for the quick fix. I've made a PR to update the version used by vcpkg: https://github.com/microsoft/vcpkg/pull/38592