summaryrefslogtreecommitdiffhomepage
path: root/include/unicode/endian.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/unicode/endian.h')
-rw-r--r--include/unicode/endian.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/unicode/endian.h b/include/unicode/endian.h
new file mode 100644
index 0000000..38bc1b7
--- /dev/null
+++ b/include/unicode/endian.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#if __cplusplus >= 202002L
+#include <bit>
+#endif
+
+namespace unicode::detail {
+
+#if __cplusplus >= 202002L
+ consteval
+#else
+ constexpr uint16_t endian_value{0x0102};
+ constexpr uint8_t endian_value_1st_byte{(const uint8_t&)endian_value};
+
+ constexpr
+#endif
+ bool is_little_endian()
+ {
+#if __cplusplus >= 202002L
+ return std::endian::native == std::endian::little;
+#else
+ return endian_value_1st_byte == 0x02;
+#endif
+ }
+
+} // namespace unicode::detail