NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
nnl::utl::utf8 Namespace Reference

Provides utilities for working with the UTF-8 encoding. More...

Functions

bool IsValid (std::string_view str)
 Checks if string contains valid UTF-8 encoding.
std::size_t GetSize (std::string_view str, std::size_t pos=0)
 Gets size of UTF-8 character at position.
char32_t Decode (std::string_view str, std::size_t pos=0)
 Decodes UTF-8 character to Unicode code point.
std::string Encode (char32_t codepoint)
 Encodes Unicode code point to UTF-8.
bool IsRightToLeft (char32_t codepoint)
 Checks if a Unicode code point belongs to a right-to-left script or has RTL directionality.
bool IsASCII (std::string_view str)
 Checks if a string contains only characters from the basic ASCII set.

Detailed Description

Provides utilities for working with the UTF-8 encoding.

Function Documentation

◆ Decode()

char32_t nnl::utl::utf8::Decode ( std::string_view str,
std::size_t pos = 0 )

Decodes UTF-8 character to Unicode code point.

Parameters
strUTF-8 string
posPosition in string
Returns
Unicode code point

◆ Encode()

std::string nnl::utl::utf8::Encode ( char32_t codepoint)

Encodes Unicode code point to UTF-8.

Parameters
codepointUnicode code point
Returns
UTF-8 encoded string

◆ GetSize()

std::size_t nnl::utl::utf8::GetSize ( std::string_view str,
std::size_t pos = 0 )

Gets size of UTF-8 character at position.

Parameters
strUTF-8 string
posPosition in string
Returns
Size in bytes of UTF-8 character (1-4)

◆ IsASCII()

bool nnl::utl::utf8::IsASCII ( std::string_view str)

Checks if a string contains only characters from the basic ASCII set.

Parameters
strstring to check
Returns
true if all characters are ASCII;

◆ IsRightToLeft()

bool nnl::utl::utf8::IsRightToLeft ( char32_t codepoint)

Checks if a Unicode code point belongs to a right-to-left script or has RTL directionality.

Parameters
codepointUnicode code point
Returns
true if RTL character, false otherwise

◆ IsValid()

bool nnl::utl::utf8::IsValid ( std::string_view str)

Checks if string contains valid UTF-8 encoding.

Parameters
strString to validate
Returns
true if valid UTF-8, false otherwise