#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <endian.h>
#ifdef USTRING_CPP0X
# include <utility>
ustring16()
: array(0), allocated(1), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const ustring16<TAlloc>& other)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const string<B, A>& other)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const std::basic_string<B, A, Alloc>& other)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(Itr first, Itr last)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const char* const c)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const char* const c, u32 length)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const uchar8_t* const c)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const char c)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const uchar8_t* const c, u32 length)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const uchar16_t* const c)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const uchar16_t* const c, u32 length)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const uchar32_t* const c)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const uchar32_t* const c, u32 length)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const wchar_t* const c)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;
ustring16(const wchar_t* const c, u32 length)
: array(0), allocated(0), used(0)
{
-#if __BIG_ENDIAN__
+#if __BYTE_ORDER == __BIG_ENDIAN
encoding = unicode::EUTFE_UTF16_BE;
#else
encoding = unicode::EUTFE_UTF16_LE;