With an example.

This commit is contained in:
Daniel Lemire 2020-06-21 17:57:22 -04:00
parent 5dbcdf1484
commit 38bb08778a
2 changed files with 22 additions and 0 deletions

View File

@ -188,6 +188,21 @@ In some cases, you may have valid JSON strings that you do not wish to parse but
Though it does not validate the JSON input, it will detect when the document ends with an unterminated string. E.g., it would refuse to minify the string `"this string is not terminated` because of the missing final quote.
UTF-8 validation (alone)
----------------------
The simdjson library has fast functions to validate UTF-8 strings. They are many times faster than most functions commonly found in libraries. You can use our fast functions, even if you do not care about JSON.
```C++
const char * some_string = "[ 1, 2, 3, 4] ";
size_t length = strlen(some_string);
bool is_ok = simdjson::validate_utf8(some_string, length);
```
Though it does not validate the JSON input, it will detect when the document ends with an unterminated string. E.g., it would refuse to minify the string `"this string is not terminated` because of the missing final quote.
C++17 Support
-------------

View File

@ -265,6 +265,13 @@ void minify() {
}
}
bool is_correct() {
const char * some_string = "[ 1, 2, 3, 4] ";
size_t length = strlen(some_string);
bool is_ok = simdjson::validate_utf8(some_string, length);
return is_ok;
}
int main() {
basics_dom_1();
basics_dom_2();