|
ZenitUI
Retained-mode C++20 UI framework
|
Zero-dependency UTF-8 encoding, decoding, grapheme-cluster navigation, and Unicode word/input classification utilities. More...
#include <cstddef>#include <cstdint>#include <string>#include <string_view>#include <vector>#include <algorithm>Go to the source code of this file.
Classes | |
| class | ZenitUI::CodepointSet |
| Composable set of Unicode codepoints for static font-atlas baking. More... | |
Functions | |
| constexpr bool | ZenitUI::Utf8::isContinuation (unsigned char b) noexcept |
true if b is a UTF-8 continuation byte (10xxxxxx). | |
| constexpr bool | ZenitUI::Utf8::isValidCodepoint (uint32_t cp) noexcept |
true if cp is a valid Unicode scalar value (excludes UTF-16 surrogates). | |
| constexpr size_t | ZenitUI::Utf8::seqLenFromLead (unsigned char b) noexcept |
| Expected UTF-8 byte length from a leading byte (1..4). | |
| size_t | ZenitUI::Utf8::encode (uint32_t cp, std::string &out) |
Append the UTF-8 encoding of cp to out. | |
| std::string | ZenitUI::Utf8::encode (uint32_t cp) |
Encode cp into a new UTF-8 std::string (empty if invalid). | |
| size_t | ZenitUI::Utf8::decode (std::string_view s, size_t pos, uint32_t &outCp) noexcept |
Decode one UTF-8 codepoint starting at byte offset pos. | |
| uint32_t | ZenitUI::Utf8::next (std::string_view s, size_t &pos) noexcept |
Decode one UTF-8 codepoint at pos and advance pos past it. | |
| size_t | ZenitUI::Utf8::snapFloor (std::string_view s, size_t pos) noexcept |
Clamp pos to s.size() and snap down to the nearest codepoint boundary. | |
| size_t | ZenitUI::Utf8::snapCeil (std::string_view s, size_t pos) noexcept |
Clamp pos to s.size() and snap up to the nearest codepoint boundary. | |
| size_t | ZenitUI::Utf8::nextCodepoint (std::string_view s, size_t pos) noexcept |
Advance pos by one UTF-8 codepoint. | |
| size_t | ZenitUI::Utf8::prevCodepoint (std::string_view s, size_t pos) noexcept |
Move pos back by one UTF-8 codepoint. | |
| size_t | ZenitUI::Utf8::codepointCount (std::string_view s) noexcept |
Count the number of UTF-8 codepoints in s. | |
| constexpr bool | ZenitUI::Utf8::isClusterExtend (uint32_t cp) noexcept |
true if cp extends the preceding grapheme cluster. | |
| constexpr bool | ZenitUI::Utf8::isRegionalIndicator (uint32_t cp) noexcept |
true if cp is a Regional Indicator symbol (U+1F1E6..U+1F1FF). | |
| size_t | ZenitUI::Utf8::nextCluster (std::string_view s, size_t pos) noexcept |
Advance pos by one grapheme cluster. | |
| size_t | ZenitUI::Utf8::prevCluster (std::string_view s, size_t pos) noexcept |
Move pos back by one grapheme cluster. | |
| std::vector< size_t > | ZenitUI::Utf8::clusterBoundaries (std::string_view s) |
Return all grapheme-cluster byte boundaries in s, starting at 0 and ending at s.size(). | |
| constexpr bool | ZenitUI::Utf8::isPrintable (uint32_t cp) noexcept |
true if cp is a printable Unicode scalar value accepted by text inputs. | |
| constexpr bool | ZenitUI::Utf8::isWordChar (uint32_t cp) noexcept |
true if cp belongs to a word (for double-click selection and Ctrl+Arrow). | |
| size_t | ZenitUI::Utf8::prevWordBoundary (std::string_view s, size_t pos) noexcept |
| Move backward to the start of the previous word (Ctrl+Left / Ctrl+Backspace). | |
| size_t | ZenitUI::Utf8::nextWordBoundary (std::string_view s, size_t pos) noexcept |
| Move forward past the current/next word (Ctrl+Right / Ctrl+Delete). | |
| std::string | ZenitUI::Utf8::sanitizeSingleLine (std::string_view src) |
| Sanitize a pasted string for single-line text fields. | |
| std::string | ZenitUI::Utf8::sanitizeMultiLine (std::string_view src) |
| Sanitize a pasted string for multi-line text fields. | |
Zero-dependency UTF-8 encoding, decoding, grapheme-cluster navigation, and Unicode word/input classification utilities.
Used by Text, TextInput, and TextArea so that cursor movement, deletion, selection, word-wrapping, and ellipsis truncation always operate on valid UTF-8 codepoint / grapheme-cluster boundaries rather than raw bytes.