11#include "../macros.hpp"
12#include "../utility/utility.hpp"
19#if defined(HI_HAS_SSE2)
23hi_export_module(hikogui.char_maps.utf_8);
28hi_warning_ignore_msvc(26490);
30hi_export
namespace hi {
inline namespace v1 {
37 using char_type =
char;
38 using fallback_encoder_type =
char_map<
"cp-1252">;
39 using fallback_char_type = fallback_encoder_type::char_type;
41 [[
nodiscard]]
constexpr std::endian guess_endian(
void const *ptr,
size_t size, std::endian endian)
const noexcept
43 return std::endian::native;
48 auto const str = std::string_view(&
cu, 1
_uz);
49 auto first = str.begin();
50 auto const[code_point, valid] = fallback_encoder_type{}.read(first, str.end());
51 return {code_point,
false};
54 template<
typename It,
typename EndIt>
64 hi_axiom(length >= 2);
77 if ((
cu & 0xc0) != 0x80) {
90 return {0xfffd,
false};
94 if ((
cu & 0b11'000000) != 0b10'000000) {
96 return {0xfffd,
false};
103 cp |=
cu & 0b00'111111;
108 valid &=
cp < 0x11'0000;
114 return {0xfffd,
false};
120 template<
typename It,
typename EndIt>
123 hi_axiom(
it != last);
138 hi_axiom(code_point < 0x11'0000);
139 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
141 return {
narrow_cast<uint8_t>((code_point > 0x7f) + (code_point > 0x7ff) + (code_point > 0xffff) + 1),
true};
144 template<
typename It>
145 constexpr void write(
char32_t code_point,
It&
dst)
const noexcept
147 hi_axiom(code_point < 0x11'0000);
148 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
184#if defined(HI_HAS_SSE2)
185 template<
typename It>
186 hi_force_inline
__m128i read_ascii_chunk16(
It it)
const noexcept
191 template<
typename It>
Definition of the CP-1252 / Windows-1252 character map.
Definition of the char_converter<From,To> functor.
@ read
Allow read access to a file.
@ write
Allow write access to a file.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
Character encoder/decoder template.
Definition char_converter.hpp:89