12#include "../macros.hpp"
17hi_warning_ignore_msvc(26490);
19namespace hi {
inline namespace v1 {
29 [[
nodiscard]] std::endian guess_endian(
void const *ptr,
size_t size, std::endian endian)
const noexcept
31 hi_assert_not_null(ptr);
32 auto *
ptr_ =
static_cast<uint8_t
const *
>(ptr);
33 hi_axiom_not_null(
ptr_);
36 return std::endian::native;
40 return std::endian::big;
42 return std::endian::little;
47 for (
auto i = 0; i != size; ++i) {
48 count[i % 4] =
ptr_[i] == 0 ? count[i % 4] + 1 : 0;
50 if (i % 4 == 0
and count[0] >= 8) {
51 return std::endian::big;
52 }
else if (i % 4 == 3
and count[3] >= 8) {
53 return std::endian::little;
61 template<
typename It,
typename EndIt>
66 if (
auto cu = *
it++;
cu < 0xd800) {
69 }
else if (
cu < 0xe000) {
71 return {0xfffd,
false};
73 }
else if (
cu < 0x11'0000) {
78 return {0xfffd,
false};
84 hi_axiom(code_point < 0x11'0000);
85 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
86 return {uint8_t{1},
true};
90 constexpr void write(
char32_t code_point,
It&
dst)
const noexcept
92 hi_axiom(code_point < 0x11'0000);
93 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
98#if defined(HI_HAS_SSE2)
135 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.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
@ 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:377
Character encoder/decoder template.
Definition char_converter.hpp:86