83 using char_type = char;
85 [[nodiscard]]
constexpr std::endian guess_endian(
void const *ptr,
size_t size, std::endian endian)
const noexcept
87 return std::endian::native;
90 template<
typename It,
typename EndIt>
95 hilet c = char_cast<char8_t>(*it++);
97 case 0x80:
return {0x20ac,
true};
98 case 0x81:
return {0x81,
true};
99 case 0x82:
return {0x201a,
true};
100 case 0x83:
return {0x0192,
true};
101 case 0x84:
return {0x201e,
true};
102 case 0x85:
return {0x2026,
true};
103 case 0x86:
return {0x2020,
true};
104 case 0x87:
return {0x2021,
true};
105 case 0x88:
return {0x02c6,
true};
106 case 0x89:
return {0x2030,
true};
107 case 0x8a:
return {0x0160,
true};
108 case 0x8b:
return {0x2039,
true};
109 case 0x8c:
return {0x0152,
true};
110 case 0x8d:
return {0x8d,
true};
111 case 0x8e:
return {0x017d,
true};
112 case 0x8f:
return {0x8f,
true};
114 case 0x90:
return {0x90,
true};
115 case 0x91:
return {0x2018,
true};
116 case 0x92:
return {0x2019,
true};
117 case 0x93:
return {0x201c,
true};
118 case 0x94:
return {0x201d,
true};
119 case 0x95:
return {0x2022,
true};
120 case 0x96:
return {0x2013,
true};
121 case 0x97:
return {0x2014,
true};
122 case 0x98:
return {0x02dc,
true};
123 case 0x99:
return {0x2122,
true};
124 case 0x9a:
return {0x0161,
true};
125 case 0x9b:
return {0x203a,
true};
126 case 0x9c:
return {0x0153,
true};
127 case 0x9d:
return {0x9d,
true};
128 case 0x9e:
return {0x017e,
true};
129 case 0x9f:
return {0x0178,
true};
130 default:
return {c,
true};
135 constexpr static auto range_0000_02DC = detail::cp_1252_make_table_0000_02DC();
136 constexpr static auto range_2000_2122 = detail::cp_1252_make_table_2000_2122();
140 hi_axiom(code_point < 0x11'0000);
141 hi_axiom(not(code_point >= 0xd800 and code_point < 0xe000));
143 if (code_point < 0x2dd) {
144 if (code_point == 0x3f) {
145 return {uint8_t{1},
true};
147 return {uint8_t{1}, range_0000_02DC[code_point] != 0x3f};
149 }
else if (code_point < 0x2000) {
150 return {uint8_t{1},
false};
152 }
else if (code_point < 0x2123) {
153 return {uint8_t{1}, range_2000_2122[code_point - 0x2000] != 0x3f};
156 return {uint8_t{1},
false};
160 template<
typename It>
161 constexpr void write(
char32_t code_point, It& dst)
const noexcept
163 hi_axiom(code_point < 0x11'0000);
164 hi_axiom(not(code_point >= 0xd800 and code_point < 0xe000));
166 if (code_point < 0x2dd) {
167 *dst++ = char_cast<char_type>(range_0000_02DC[code_point]);
169 }
else if (code_point < 0x2000) {
170 *dst++ = char_cast<char_type>(0x3f);
172 }
else if (code_point < 0x2123) {
173 *dst++ = char_cast<char_type>(range_2000_2122[code_point - 0x2000]);
176 *dst++ = char_cast<char_type>(0x3f);
180#if defined(HI_HAS_SSE2)
181 template<
typename It>
182 hi_force_inline __m128i read_ascii_chunk16(It it)
const noexcept
184 return _mm_loadu_si128(
reinterpret_cast<__m128i
const *
>(
std::addressof(*it)));
187 template<
typename It>
188 hi_force_inline
void write_ascii_chunk16(__m128i chunk, It dst)
const noexcept
190 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(
std::addressof(*dst)), chunk);