Fixing...
This commit is contained in:
parent
b836164a38
commit
a76c67c19f
|
@ -200,7 +200,7 @@ The simdjson library has fast functions to validate UTF-8 strings. They are many
|
|||
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.
|
||||
The UTF-8 validation function merely checks that the input is valid UTF-8: it works with strings in general, not just JSON strings.
|
||||
|
||||
|
||||
C++17 Support
|
||||
|
|
|
@ -26,7 +26,19 @@ WARN_UNUSED bool validate_utf8(const char * buf, size_t length) noexcept;
|
|||
* @param p the string_view to validate.
|
||||
* @return true if the string is valid UTF-8.
|
||||
*/
|
||||
WARN_UNUSED bool validate_utf8(std::string_view& p) noexcept;
|
||||
really_inline WARN_UNUSED bool validate_utf8(const std::string_view& p) noexcept {
|
||||
return validate_utf8(p.data(), p.size());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the UTF-8 string.
|
||||
*
|
||||
* @param p the string_view to validate.
|
||||
* @return true if the string is valid UTF-8.
|
||||
*/
|
||||
really_inline WARN_UNUSED bool validate_utf8(const std::string& p) noexcept {
|
||||
return validate_utf8(p.data(), p.size());
|
||||
}
|
||||
|
||||
namespace dom {
|
||||
class document;
|
||||
|
|
|
@ -272,6 +272,20 @@ bool is_correct() {
|
|||
return is_ok;
|
||||
}
|
||||
|
||||
bool is_correct_string_view() {
|
||||
const char * some_string = "[ 1, 2, 3, 4] ";
|
||||
size_t length = strlen(some_string);
|
||||
std::string_view v(some_string, length);
|
||||
bool is_ok = simdjson::validate_utf8(v);
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
bool is_correct_string() {
|
||||
const std::string some_string = "[ 1, 2, 3, 4] ";
|
||||
bool is_ok = simdjson::validate_utf8(some_string);
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
int main() {
|
||||
basics_dom_1();
|
||||
basics_dom_2();
|
||||
|
|
Loading…
Reference in New Issue