irccd  3.0.3
Functions
irccd::unicode Namespace Reference

Unicode namespace. More...

Functions

void encode (char32_t point, char res[5]) noexcept
 
void decode (char32_t &c, const char *res) noexcept
 
auto nbytes_utf8 (char c) noexcept -> int
 
auto nbytes_point (char32_t point) noexcept -> int
 
auto length (std::string_view str) -> unsigned
 
template<typename Func >
void for_each (std::string_view str, Func function)
 
auto to_utf8 (std::u32string_view array) -> std::string
 
auto to_utf32 (std::string_view str) -> std::u32string
 
auto isspace (char32_t c) noexcept -> bool
 
auto isdigit (char32_t c) noexcept -> bool
 
auto isalpha (char32_t c) noexcept -> bool
 
auto isupper (char32_t c) noexcept -> bool
 
auto islower (char32_t c) noexcept -> bool
 
auto istitle (char32_t c) noexcept -> bool
 
auto toupper (char32_t c) noexcept -> char32_t
 
auto tolower (char32_t c) noexcept -> char32_t
 
auto totitle (char32_t c) noexcept -> char32_t
 
auto toupper (std::u32string_view str) -> std::u32string
 
auto toupper (std::string_view str) -> std::string
 
auto tolower (std::u32string_view str) -> std::u32string
 
auto tolower (std::string_view str) -> std::string
 

Detailed Description

Unicode namespace.

Function Documentation

◆ decode()

void irccd::unicode::decode ( char32_t &  c,
const char *  res 
)
noexcept

Decode the multibyte buffer into an unicode code point.

Parameters
cthe code point destination
resthe multibyte string.

◆ encode()

void irccd::unicode::encode ( char32_t  point,
char  res[5] 
)
noexcept

Encode the unicode code point into multibyte string.

Parameters
pointthe unicode code point
resthe output buffer

◆ for_each()

template<typename Func >
void irccd::unicode::for_each ( std::string_view  str,
Func  function 
)

Iterate over all real characters in the UTF-8 string.

The function must have the following signature: void f(char ch)

Parameters
strthe UTF-8 string
functionthe function callback
Exceptions
std::invalid_argumenton invalid sequence

◆ isalpha()

auto irccd::unicode::isalpha ( char32_t  c) -> bool
noexcept

Check if the unicode character is alpha category.

Parameters
cthe character
Returns
true if alpha

◆ isdigit()

auto irccd::unicode::isdigit ( char32_t  c) -> bool
noexcept

Check if the unicode character is digit.

Parameters
cthe character
Returns
true if digit

◆ islower()

auto irccd::unicode::islower ( char32_t  c) -> bool
noexcept

Check if the unicode character is lower case.

Parameters
cthe character
Returns
true if lower case

◆ isspace()

auto irccd::unicode::isspace ( char32_t  c) -> bool
noexcept

Check if the unicode character is space.

Parameters
cthe character
Returns
true if space

◆ istitle()

auto irccd::unicode::istitle ( char32_t  c) -> bool
noexcept

Check if the unicode character is title case.

Parameters
cthe character
Returns
true if title case

◆ isupper()

auto irccd::unicode::isupper ( char32_t  c) -> bool
noexcept

Check if the unicode character is upper case.

Parameters
cthe character
Returns
true if upper case

◆ length()

auto irccd::unicode::length ( std::string_view  str) -> unsigned

Get real number of character in a string.

Parameters
strthe string
Returns
the length
Exceptions
std::invalid_argumenton invalid sequence

◆ nbytes_point()

auto irccd::unicode::nbytes_point ( char32_t  point) -> int
noexcept

Get the number of bytes for the unicode point.

Parameters
pointthe unicode point
Returns
the number of bytes [1-4] or -1 if invalid

◆ nbytes_utf8()

auto irccd::unicode::nbytes_utf8 ( char  c) -> int
noexcept

Get the number of bytes for the first multi byte character from a utf-8 string.

This can be used to iterate a valid UTF-8 string to jump to the next real character.

Parameters
cthe first multi byte character
Returns
the number of bytes [1-4] or -1 if invalid

◆ to_utf32()

auto irccd::unicode::to_utf32 ( std::string_view  str) -> std::u32string

Convert a UTF-8 string to UTF-32 string.

Parameters
strthe UTF-8 string
Returns
the UTF-32 string
Exceptions
std::invalid_argumenton invalid sequence

◆ to_utf8()

auto irccd::unicode::to_utf8 ( std::u32string_view  array) -> std::string

Convert a UTF-32 string to UTF-8 string.

Parameters
arraythe UTF-32 string
Returns
the UTF-8 string
Exceptions
std::invalid_argumenton invalid sequence

◆ tolower() [1/3]

auto irccd::unicode::tolower ( char32_t  c) -> char32_t
noexcept

Convert to lower case.

Parameters
cthe character
Returns
the lower case character

◆ tolower() [2/3]

auto irccd::unicode::tolower ( std::string_view  str) -> std::string

Convert the UTF-8 string to lower case.

Parameters
strthe string
Returns
the lower case string
Warning
very slow at the moment

◆ tolower() [3/3]

auto irccd::unicode::tolower ( std::u32string_view  str) -> std::u32string

Convert the UTF-32 string to lower case.

Parameters
strthe string
Returns
the lower case string

◆ totitle()

auto irccd::unicode::totitle ( char32_t  c) -> char32_t
noexcept

Convert to title case.

Parameters
cthe character
Returns
the title case character

◆ toupper() [1/3]

auto irccd::unicode::toupper ( char32_t  c) -> char32_t
noexcept

Convert to upper case.

Parameters
cthe character
Returns
the upper case character

◆ toupper() [2/3]

auto irccd::unicode::toupper ( std::string_view  str) -> std::string

Convert the UTF-8 string to upper case.

Parameters
strthe string
Returns
the upper case string
Warning
very slow at the moment

◆ toupper() [3/3]

auto irccd::unicode::toupper ( std::u32string_view  str) -> std::u32string

Convert the UTF-32 string to upper case.

Parameters
strthe string
Returns
the upper case string