Unicode namespace.
More...
|
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 |
|
◆ decode()
void irccd::unicode::decode |
( |
char32_t & |
c, |
|
|
const char * |
res |
|
) |
| |
|
noexcept |
Decode the multibyte buffer into an unicode code point.
- Parameters
-
c | the code point destination |
res | the multibyte string. |
◆ encode()
void irccd::unicode::encode |
( |
char32_t |
point, |
|
|
char |
res[5] |
|
) |
| |
|
noexcept |
Encode the unicode code point into multibyte string.
- Parameters
-
point | the unicode code point |
res | the 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
-
str | the UTF-8 string |
function | the function callback |
- Exceptions
-
std::invalid_argument | on invalid sequence |
◆ isalpha()
auto irccd::unicode::isalpha |
( |
char32_t |
c | ) |
-> bool |
|
noexcept |
Check if the unicode character is alpha category.
- Parameters
-
- Returns
- true if alpha
◆ isdigit()
auto irccd::unicode::isdigit |
( |
char32_t |
c | ) |
-> bool |
|
noexcept |
Check if the unicode character is digit.
- Parameters
-
- Returns
- true if digit
◆ islower()
auto irccd::unicode::islower |
( |
char32_t |
c | ) |
-> bool |
|
noexcept |
Check if the unicode character is lower case.
- Parameters
-
- Returns
- true if lower case
◆ isspace()
auto irccd::unicode::isspace |
( |
char32_t |
c | ) |
-> bool |
|
noexcept |
Check if the unicode character is space.
- Parameters
-
- Returns
- true if space
◆ istitle()
auto irccd::unicode::istitle |
( |
char32_t |
c | ) |
-> bool |
|
noexcept |
Check if the unicode character is title case.
- Parameters
-
- Returns
- true if title case
◆ isupper()
auto irccd::unicode::isupper |
( |
char32_t |
c | ) |
-> bool |
|
noexcept |
Check if the unicode character is upper case.
- Parameters
-
- Returns
- true if upper case
◆ length()
auto irccd::unicode::length |
( |
std::string_view |
str | ) |
-> unsigned |
Get real number of character in a string.
- Parameters
-
- Returns
- the length
- Exceptions
-
std::invalid_argument | on invalid sequence |
◆ nbytes_point()
auto irccd::unicode::nbytes_point |
( |
char32_t |
point | ) |
-> int |
|
noexcept |
Get the number of bytes for the unicode point.
- Parameters
-
- 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
-
c | the 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
-
- Returns
- the UTF-32 string
- Exceptions
-
std::invalid_argument | on 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
-
- Returns
- the UTF-8 string
- Exceptions
-
std::invalid_argument | on invalid sequence |
◆ tolower() [1/3]
auto irccd::unicode::tolower |
( |
char32_t |
c | ) |
-> char32_t |
|
noexcept |
Convert to lower case.
- Parameters
-
- 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
-
- 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
-
- Returns
- the lower case string
◆ totitle()
auto irccd::unicode::totitle |
( |
char32_t |
c | ) |
-> char32_t |
|
noexcept |
Convert to title case.
- Parameters
-
- Returns
- the title case character
◆ toupper() [1/3]
auto irccd::unicode::toupper |
( |
char32_t |
c | ) |
-> char32_t |
|
noexcept |
Convert to upper case.
- Parameters
-
- 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
-
- 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
-
- Returns
- the upper case string