11#include "../utility/utility.hpp"
12#include "../macros.hpp"
17#if defined(HI_HAS_SSE2)
21hi_export_module(hikogui.char_maps.utf_16);
26hi_warning_ignore_msvc(26490);
28hi_export
namespace hi {
inline namespace v1 {
38 [[
nodiscard]] std::endian guess_endian(
void const *ptr,
size_t size, std::endian endian)
const noexcept
40 hi_assert_not_null(ptr);
41 auto *
ptr_ =
static_cast<uint8_t
const *
>(ptr);
42 hi_axiom_not_null(
ptr_);
45 return std::endian::native;
49 return std::endian::big;
51 return std::endian::little;
56 for (
auto i = 0; i != size; ++i) {
57 count[i % 2] =
ptr_[i] == 0 ? count[i % 2] + 1 : 0;
58 if (count[i % 2] >= 8) {
59 return i % 2 == 0 ? std::endian::big : std::endian::little;
67 template<
typename It,
typename EndIt>
72 if (
auto cu = *
it++;
cu < 0xd800) {
75 }
else if (
cu < 0xdc00) {
78 return {0xfffd,
false};
83 if (
cu >= 0xdc00
and cu < 0xe000) {
92 return {0xfffd,
false};
96 }
else if (
cu < 0xe000) {
98 return {0xfffd,
false};
107 hi_axiom(code_point < 0x11'0000);
108 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
112 template<
typename It>
113 constexpr void write(
char32_t code_point,
It&
dst)
const noexcept
115 hi_axiom(code_point <= 0x10'ffff);
116 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
127#if defined(HI_HAS_SSE2)
128 template<
typename It>
129 hi_force_inline
__m128i read_ascii_chunk16(
It it)
const noexcept
157 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