validate

group turbo_unicode_validate

Functions

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline bool validate_utf8(const char *buf, size_t len) noexcept

validate_utf8 check whether input buffer is valid utf8.

using this function is faster than validate_utf8_with_errors but it will not return error position.

See also

validate_utf8_with_errors.

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

true if valid utf8, otherwise false

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline UnicodeResult validate_utf8_with_errors(const char *buf, size_t len) noexcept

validate_utf8_with_errors check whether input buffer is valid utf8.

using this function is slower than validate_utf8 but it will return error position.

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

UnicodeResult, if valid utf8, UnicodeResult is ok, otherwise UnicodeResult is error and error position is set.

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
bool validate_ascii(const char *buf, size_t len) noexcept

validate_ascii check whether input buffer is valid ascii.

using this function is faster than validate_ascii_with_errors. but it will not return error position.

See also

validate_ascii_with_errors. Example:

auto is_ascii = validate_ascii(input, length);
// is_ascii is true if input is valid ascii, otherwise false
If you want to use your own engine, you can use like this:
auto is_ascii = validate_ascii<YourEngine>(input, length);
// is_ascii is true if input is valid ascii, otherwise false

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

true if valid ascii, otherwise false

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline UnicodeResult validate_ascii_with_errors(const char *buf, size_t len) noexcept

validate_ascii_with_errors check whether input buffer is valid ascii.

using this function is slower than validate_ascii. but it will return error position. Example:

auto result = validate_ascii_with_errors(input, length);
// result is ok if input is valid ascii, otherwise result is error and error position is set.
If you want to use your own engine, you can use like this:
auto result = validate_ascii_with_errors<YourEngine>(input, length);
// result is ok if input is valid ascii, otherwise result is error and error position is set.

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

result, if valid ascii, result is ok, otherwise result is error and error position is set.

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline bool validate_utf16(const char16_t *buf, size_t len) noexcept

validate_utf16 check whether input buffer is valid utf16.

using this function is faster than validate_utf16_with_errors. but it will not return error position.

See also

validate_utf16_with_errors. @bote this function will auto detect utf16 endian as host endian. input buffer must be host endian. Example:

auto is_utf16 = validate_utf16(input, length);
// is_utf16 is true if input is valid utf16, otherwise false
If you want to use your own engine, you can use like this:
auto is_utf16 = validate_utf16<YourEngine>(input, length);
// is_utf16 is true if input is valid utf16, otherwise false

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

true if valid utf16, otherwise false

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline bool validate_utf16le(const char16_t *buf, size_t len) noexcept

check whether input buffer is valid utf16 with little endian.

See also

also validate_utf16

Note

guard that input buffer is little endian.

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

true if valid utf16, otherwise false

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline bool validate_utf16be(const char16_t *buf, size_t len) noexcept

check whether input buffer is valid utf16 with big endian.

See also

also validate_utf16

Note

guard that input buffer is big endian.

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

true if valid utf16, otherwise false

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline UnicodeResult validate_utf16_with_errors(const char16_t *buf, size_t len) noexcept

validate_utf16_with_errors check whether input buffer is valid utf16.

using this function is slower than validate_utf16. but it will return error position. @bote this function will auto detect utf16 endian as host endian. input buffer must be host endian. Example:

auto result = validate_utf16_with_errors(input, length);
// result is ok if input is valid utf16, otherwise result is error and error position is set.
If you want to use your own engine, you can use like this:
auto result = validate_utf16_with_errors<YourEngine>(input, length);
// result is ok if input is valid utf16, otherwise result is error and error position is set.

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

result, if valid utf16, result is ok, the position is the len input , otherwise result is error and error position is set.

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline UnicodeResult validate_utf16le_with_errors(const char16_t *buf, size_t len) noexcept

check whether input buffer is valid utf16 with little endian.

See also

also validate_utf16_with_errors

See also

also validate_utf16le

Note

guard that input buffer is little endian.

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

result, if valid utf16, result is ok, the position is the len input , otherwise result is error and error position is set.

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline UnicodeResult validate_utf16be_with_errors(const char16_t *buf, size_t len) noexcept

check whether input buffer is valid utf16 with big endian.

See also

also validate_utf16_with_errors

See also

also validate_utf16be

Note

guard that input buffer is big endian.

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

result, if valid utf16, result is ok, the position is the len input , otherwise result is error and error position is set.

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline bool validate_utf32(const char32_t *buf, size_t len) noexcept

validate_utf32 check whether input buffer is valid utf32.

using this function is faster than validate_utf32_with_errors. but it will not return error position.

See also

validate_utf32_with_errors. @bote this function will auto detect utf32 endian as host endian. input buffer must be host endian. Example:

auto is_utf32 = validate_utf32(input, length);
// is_utf32 is true if input is valid utf32, otherwise false
If you want to use your own engine, you can use like this:
auto is_utf32 = validate_utf32<YourEngine>(input, length);
// is_utf32 is true if input is valid utf32, otherwise false

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

true if valid utf32, otherwise false

template<typename Engine = turbo::unicode::default_engine, typename turbo::check_requires<turbo::unicode::is_unicode_engine<Engine>> = 0>
inline UnicodeResult validate_utf32_with_errors(const char32_t *buf, size_t len) noexcept

check whether input buffer is valid utf32 with little endian.

See also

also validate_utf32

Note

guard that input buffer is little endian.

Note

guard that input buffer is little endian.

Template Parameters:

Engine – default is turbo::unicode::default_engine

Parameters:
  • buf – buffer to check

  • len – buffer length

Returns:

true if valid utf32, otherwise false