12#include "../utility/utility.hpp"
13#include "../macros.hpp"
18#if defined(HI_HAS_SSE2)
22hi_export_module(hikogui.char_maps.utf_32);
27hi_warning_ignore_msvc(26490);
29hi_export
namespace hi {
inline namespace v1 {
39 [[
nodiscard]] std::endian guess_endian(
void const *ptr,
size_t size, std::endian endian)
const noexcept
41 hi_assert_not_null(ptr);
42 auto *
ptr_ =
static_cast<uint8_t
const *
>(ptr);
43 hi_axiom_not_null(
ptr_);
46 return std::endian::native;
50 return std::endian::big;
52 return std::endian::little;
57 for (
auto i = 0; i != size; ++i) {
58 count[i % 4] =
ptr_[i] == 0 ? count[i % 4] + 1 : 0;
60 if (i % 4 == 0
and count[0] >= 8) {
61 return std::endian::big;
62 }
else if (i % 4 == 3
and count[3] >= 8) {
63 return std::endian::little;
71 template<
typename It,
typename EndIt>
76 if (
auto cu = *
it++;
cu < 0xd800) {
79 }
else if (
cu < 0xe000) {
81 return {0xfffd,
false};
83 }
else if (
cu < 0x11'0000) {
88 return {0xfffd,
false};
94 hi_axiom(code_point < 0x11'0000);
95 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
96 return {uint8_t{1},
true};
100 constexpr void write(
char32_t code_point,
It&
dst)
const noexcept
102 hi_axiom(code_point < 0x11'0000);
103 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
108#if defined(HI_HAS_SSE2)
109 template<
typename It>
110 hi_force_inline
__m128i read_ascii_chunk16(
It it)
const noexcept
145 template<
typename It>
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
@ zero
The number was zero, and this means something in the current language.
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