UTF8 text utilities.
More...
◆ GetCodePointsCount()
std::size_t utils::text::utf8::GetCodePointsCount |
( |
std::string_view |
text | ) |
|
returns number of utf-8 code points, text must be in utf-8 encoding
- Exceptions
-
std::runtime_error | if not a valid UTF8 text |
◆ GetTextPosByCodePointPos()
std::size_t utils::text::utf8::GetTextPosByCodePointPos |
( |
std::string_view |
text, |
|
|
std::size_t |
pos |
|
) |
| |
|
noexcept |
Returns position in text
where utf-8 code point with position pos
starts OR text.length()
if text
contains less than or equal to pos
points
- Warning
- this does not check if
text
is valid utf-8 text
◆ RemovePrefix()
void utils::text::utf8::RemovePrefix |
( |
std::string & |
text, |
|
|
std::size_t |
count |
|
) |
| |
|
noexcept |
Removes the first count
utf-8 code points from text
- Warning
- this does not check if
text
is valid utf-8 text
◆ RemoveViewPrefix()
void utils::text::utf8::RemoveViewPrefix |
( |
std::string_view & |
text, |
|
|
std::size_t |
count |
|
) |
| |
|
noexcept |
◆ TakePrefix()
void utils::text::utf8::TakePrefix |
( |
std::string & |
text, |
|
|
std::size_t |
count |
|
) |
| |
|
noexcept |
Takes the first count
utf-8 code points from text
- Warning
- this does not check if
text
is valid utf-8 text
◆ TakeViewPrefix()
void utils::text::utf8::TakeViewPrefix |
( |
std::string_view & |
text, |
|
|
std::size_t |
count |
|
) |
| |
|
noexcept |
◆ TrimTruncatedEnding()
void utils::text::utf8::TrimTruncatedEnding |
( |
std::string & |
str | ) |
|
Removes the longest (possible empty) suffix of str
which is a proper prefix of some utf-8 multibyte character. If str
is not in utf-8 it may remove some suffix of length up to 3.
◆ TrimViewTruncatedEnding()
void utils::text::utf8::TrimViewTruncatedEnding |
( |
std::string_view & |
view | ) |
|