nxt/utf8.hpp file

Namespaces

namespace nxt
namespace nxt::utf8
namespace nxt::utf8::detail

Classes

struct nxt::utf8::byte_offset_t
Byte offset into a UTF-8 string.
struct nxt::utf8::grapheme_index_t
Grapheme-cluster index into a UTF-8 string.
struct nxt::utf8::detail::Decoded
struct nxt::utf8::word
One non-separator word and its display width.
struct nxt::utf8::text_segment
Word or line-break segment used for streaming/wrapping text.
class nxt::utf8::word_view
Forward range over non-separator words in a string view.
class nxt::utf8::word_view::iterator
Iterator over words.
class nxt::utf8::segment_view
Forward range over words and line breaks in a string view.
class nxt::utf8::segment_view::iterator
Iterator over text segments.

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 decode(std::string_view text, byte_offset_t byte) →  Decoded noexcept
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 regional_indicator(utf8proc_int32_t cp) →  bool 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.