8#include "unicode_normalization.hpp"
9#include "unicode_grapheme_cluster_break.hpp"
10#include "../utility/module.hpp"
11#include "../strings.hpp"
18 using char_type = hi::grapheme;
19 using int_type = std::make_signed_t<char_type::value_type>;
23 using comparison_category = std::strong_ordering;
25 static constexpr void assign(char_type& r, char_type
const& a)
noexcept
39 [[nodiscard]]
static constexpr bool eq(char_type a, char_type b)
noexcept
44 [[nodiscard]]
static constexpr bool lt(char_type a, char_type b)
noexcept
49 static constexpr char_type *
move(char_type *dst, char_type
const *src,
std::size_t count)
noexcept
60 dst[i - 1] = src[i - 1];
66 static constexpr char_type *
copy(char_type *dst, char_type
const *src,
std::size_t count)
noexcept
84 return s1[i] < s2[i] ? -1 : 1;
95 while (s[i] !=
'\0') {
101 static constexpr char_type
const *
find(
const char_type *p,
std::size_t count,
const char_type& ch)
noexcept
113 static constexpr char_type
to_char_type(int_type c)
noexcept
115 return c < 0 ? char_type{U
'\ufffd'} : char_type{
hi::intrinsic_t{}, hi::char_cast<char_type::value_type>(c)};
118 static constexpr int_type
to_int_type(char_type c)
noexcept
120 return hi::char_cast<int_type>(c.intrinsic());
123 static constexpr bool eq_int_type(int_type c1, int_type c2)
noexcept
128 static constexpr int_type
eof()
noexcept
133 static constexpr int_type
not_eof(int_type e)
noexcept
135 return e < 0 ? 0 : e;
139namespace hi::inline
v1 {
142using gstring_view = std::basic_string_view<grapheme>;
145using gstring = std::pmr::basic_string<grapheme>;
157[[nodiscard]]
constexpr gstring
163 auto break_state = detail::grapheme_break_state{};
166 for (
hilet code_point : normalized_string) {
167 if (detail::breaks_grapheme(code_point, break_state)) {
168 if (cluster.size() > 0) {
174 cluster += code_point;
176 if (ssize(cluster) != 0) {
191[[nodiscard]]
constexpr gstring
206[[nodiscard]]
constexpr gstring
209 return to_gstring(std::string_view{rhs}, config);
217[[nodiscard]]
constexpr std::string to_string(gstring_view rhs)
noexcept
221 for (
hilet c : rhs) {
232[[nodiscard]]
constexpr std::wstring to_wstring(gstring_view rhs)
noexcept
236 for (
hilet c : rhs) {
251 for (
hilet c : rhs) {
252 r += to_u32string(c);
264 return to_string(gstring_view{rhs});
274 for (
hilet c : rhs) {
286 for (
hilet c : rhs) {
#define hi_axiom_not_null(expression,...)
Assert if an expression is not nullptr.
Definition assert.hpp:272
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
constexpr gstring to_gstring(std::u32string_view rhs, unicode_normalize_config config=unicode_normalize_config::NFC()) noexcept
Convert a UTF-32 string-view to a grapheme-string.
Definition gstring.hpp:158
constexpr std::u32string unicode_normalize(std::u32string_view text, unicode_normalize_config config=unicode_normalize_config::NFC()) noexcept
Convert text to a Unicode composed normal form.
Definition unicode_normalization.hpp:303
geometry/margins.hpp
Definition cache.hpp:11
Definition grapheme.hpp:31
A grapheme-cluster, what a user thinks a character is.
Definition grapheme.hpp:44
Definition unicode_normalization.hpp:19
Tag used in constructors to set the intrinsic value of that object.
Definition utility.hpp:230
T to_char_type(T... args)