utf8 namespace
Namespaces
- namespace detail
Classes
- struct byte_offset_t
- Byte offset into a UTF-8 string.
- struct grapheme_index_t
- Grapheme-cluster index into a UTF-8 string.
- class segment_view
- Forward range over words and line breaks in a string view.
- struct text_segment
- Word or line-break segment used for streaming/wrapping text.
- struct word
- One non-separator word and its display width.
- class word_view
- Forward range over non-separator words in a string view.
Functions
-
auto byte_at(std::
string_view text, grapheme_ index_ t cell) → byte_ offset_ t noexcept - Byte offset at the
cell-th grapheme cluster (clamped to text.size()). -
auto byte_at_column(std::
string_view text, width_ t column) → byte_ offset_ t noexcept - Byte offset for the grapheme cluster at
column. -
auto byte_offset(std::
size_t n) → byte_ offset_ t constexpr noexcept - Construct a byte offset.
-
auto cell_at(std::
string_view text, byte_ offset_ t byte) → grapheme_ index_ t noexcept - Grapheme cluster index for a byte offset, snapped to the previous boundary.
-
auto cluster_width(std::
string_view cluster) → width_ t noexcept - Display width of one grapheme cluster.
-
auto column_at(std::
string_view text, byte_ offset_ t byte) → width_ t noexcept - Display column for a byte offset, snapped to the previous boundary.
-
auto complete_words_prefix_size(std::
string_view text) → std:: size_t noexcept - Size in bytes of the prefix that ends on a word boundary.
-
auto count(std::
string_view text) → grapheme_ index_ t noexcept - Number of grapheme clusters in
text. -
auto display_width(std::
string_view text) → width_ t noexcept - Display width of all grapheme clusters in
text. -
auto floor_boundary(std::
string_view text, byte_ offset_ t byte) → byte_ offset_ t noexcept - Byte offset of the nearest grapheme boundary at or before
byte. -
auto grapheme_index(std::
size_t n) → grapheme_ index_ t constexpr noexcept - Construct a grapheme index.
-
auto is_line_break(std::
string_view cluster) → bool noexcept - True when a grapheme cluster is a line break.
-
auto is_word_separator(std::
string_view cluster) → bool noexcept - True when a grapheme cluster should separate words.
-
auto next(std::
string_view text, byte_ offset_ t byte) → byte_ offset_ t noexcept -
auto operator-(byte_
offset_ t a, byte_ offset_ t b) → std:: size_t constexpr noexcept - Difference between two byte offsets.
-
auto prev(std::
string_view text, byte_ offset_ t byte) → byte_ offset_ t noexcept -
auto segments(std::
string_view text) → segment_ view noexcept - Return a segment range over borrowed text.
-
auto words(std::
string_view text) → word_ view noexcept - Return a word range over borrowed text.
Function documentation
byte_ offset_ t nxt:: utf8:: byte_at(std:: string_view text,
grapheme_ index_ t cell) noexcept
#include <nxt/utf8.hpp>
Byte offset at the cell-th grapheme cluster (clamped to text.size()).
byte_ offset_ t nxt:: utf8:: byte_at_column(std:: string_view text,
width_ t column) noexcept
#include <nxt/utf8.hpp>
Byte offset for the grapheme cluster at column.
byte_ offset_ t nxt:: utf8:: byte_offset(std:: size_t n) constexpr noexcept
#include <nxt/utf8.hpp>
Construct a byte offset.
grapheme_ index_ t nxt:: utf8:: cell_at(std:: string_view text,
byte_ offset_ t byte) noexcept
#include <nxt/utf8.hpp>
Grapheme cluster index for a byte offset, snapped to the previous boundary.
width_ t nxt:: utf8:: cluster_width(std:: string_view cluster) noexcept
#include <nxt/utf8.hpp>
Display width of one grapheme cluster.
width_ t nxt:: utf8:: column_at(std:: string_view text,
byte_ offset_ t byte) noexcept
#include <nxt/utf8.hpp>
Display column for a byte offset, snapped to the previous boundary.
std:: size_t nxt:: utf8:: complete_words_prefix_size(std:: string_view text) noexcept
#include <nxt/utf8.hpp>
Size in bytes of the prefix that ends on a word boundary.
grapheme_ index_ t nxt:: utf8:: count(std:: string_view text) noexcept
#include <nxt/utf8.hpp>
Number of grapheme clusters in text.
width_ t nxt:: utf8:: display_width(std:: string_view text) noexcept
#include <nxt/utf8.hpp>
Display width of all grapheme clusters in text.
byte_ offset_ t nxt:: utf8:: floor_boundary(std:: string_view text,
byte_ offset_ t byte) noexcept
#include <nxt/utf8.hpp>
Byte offset of the nearest grapheme boundary at or before byte.
grapheme_ index_ t nxt:: utf8:: grapheme_index(std:: size_t n) constexpr noexcept
#include <nxt/utf8.hpp>
Construct a grapheme index.
bool nxt:: utf8:: is_line_break(std:: string_view cluster) noexcept
#include <nxt/utf8.hpp>
True when a grapheme cluster is a line break.
bool nxt:: utf8:: is_word_separator(std:: string_view cluster) noexcept
#include <nxt/utf8.hpp>
True when a grapheme cluster should separate words.
byte_ offset_ t nxt:: utf8:: next(std:: string_view text,
byte_ offset_ t byte) noexcept
#include <nxt/utf8.hpp>
Byte offset of the grapheme cluster after the one starting at byte. Returns text.size() if byte is at or past the end.
std:: size_t nxt:: utf8:: operator-(byte_ offset_ t a,
byte_ offset_ t b) constexpr noexcept
#include <nxt/utf8.hpp>
Difference between two byte offsets.
byte_ offset_ t nxt:: utf8:: prev(std:: string_view text,
byte_ offset_ t byte) noexcept
#include <nxt/utf8.hpp>
Byte offset of the grapheme cluster before the one ending at byte. Returns 0 if byte is at the start.
segment_ view nxt:: utf8:: segments(std:: string_view text) noexcept
#include <nxt/utf8.hpp>
Return a segment range over borrowed text.
word_ view nxt:: utf8:: words(std:: string_view text) noexcept
#include <nxt/utf8.hpp>
Return a word range over borrowed text.