BloombergLP::bdlde::Utf8Util

Utility for validating and navigating UTF-8 encoded strings.

Synopsis

Declared in <bdlde_utf8util.h>

struct Utf8Util;

Description

This struct provides a namespace for static methods used for validating UTF-8 strings, for counting the number of Unicode code points in them, for advancing pointers through UTF-8 strings by a specified number of Unicode code points, for counting the number of bytes a UTF-8 leading substring occupies, for counting the number of bytes in a UTF-8 character, and for appending a Unicode character to a UTF-8 string.

Type Aliases

NameDescription
IntPtr This typedef is an alias to bsls::Types::IntPtr.
Uint64 This typedef is an alias to bsls::Types::Uint64.
UintPtr This typedef is an alias to bsls::Types::UintPtr.
size_type This typedef is an alias to bsls::Types::size_type.

Enums

NameDescription
Unnamed enum Substitution code point constants.
ErrorStatus Negative status codes returned when UTF-8 validation fails.

Static Member Functions

NameDescription
advanceIfValid advanceIfValid overloads
advanceRaw advanceRaw overloads
appendUtf8Character Append the UTF-8 encoding of codePoint to output.
appendUtf8CodePoint Append the UTF-8 encoding of codePoint to output.
codePointValue Return the numeric value of the UTF-8 code point at codePoint.
getByteSize Return the byte length of the UTF-8 code point at codePoint.
getLineAndColumnNumber Load line and column information for byteOffset in input.
isValid isValid overloads
isValidCodePoint Return whether codePoint begins a valid UTF-8 code point.
numBytesIfValid Return the byte length of the first numCodePoints encodings.
numBytesInCodePoint Return the byte length of the UTF-8 code point at codePoint.
numBytesRaw Return the byte length of the first numCodePoints encodings.
numCharacters numCharacters overloads
numCharactersIfValid Return the Unicode code-point count if string is valid UTF-8.
numCharactersRaw numCharactersRaw overloads
numCodePointsIfValid numCodePointsIfValid overloads
numCodePointsRaw Return the Unicode code-point count in string.
readIfValid Copy valid UTF-8 from input into outputBuffer.
replaceErrors Replace UTF-8 error sequences in input and write to output.
toAscii Return the string name of the ErrorStatus enumerator for value.