11#include "../macros.hpp"
16hi_warning_ignore_msvc(26490);
18namespace hi {
inline namespace v1 {
28 [[
nodiscard]] std::endian guess_endian(
void const *ptr,
size_t size, std::endian endian)
const noexcept
30 hi_assert_not_null(ptr);
31 auto *
ptr_ =
static_cast<uint8_t
const *
>(ptr);
32 hi_axiom_not_null(
ptr_);
35 return std::endian::native;
39 return std::endian::big;
41 return std::endian::little;
46 for (
auto i = 0; i != size; ++i) {
47 count[i % 2] =
ptr_[i] == 0 ? count[i % 2] + 1 : 0;
48 if (count[i % 2] >= 8) {
49 return i % 2 == 0 ? std::endian::big : std::endian::little;
57 template<
typename It,
typename EndIt>
62 if (
auto cu = *
it++;
cu < 0xd800) {
65 }
else if (
cu < 0xdc00) {
68 return {0xfffd,
false};
73 if (
cu >= 0xdc00
and cu < 0xe000) {
82 return {0xfffd,
false};
86 }
else if (
cu < 0xe000) {
88 return {0xfffd,
false};
97 hi_axiom(code_point < 0x11'0000);
98 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
102 template<
typename It>
103 constexpr void write(
char32_t code_point,
It&
dst)
const noexcept
105 hi_axiom(code_point <= 0x10'ffff);
106 hi_axiom(
not(code_point >= 0xd800
and code_point < 0xe000));
117#if defined(HI_HAS_SSE2)
118 template<
typename It>
147 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