#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#ifdef _WIN32
+#define __BYTE_ORDER 0
+#define __LITTLE_ENDIAN 0
+#define __BIG_ENDIAN 1
+#elif defined(__MACH__) && defined(__APPLE__)
+#include <machine/endian.h>
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
+#else
+#include <endian.h>
+#endif
#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;
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const short left, const ustring16<TAlloc>& right)
{
- ustring16<TAlloc> ret(core::stringc(left));
+ ustring16<TAlloc> ret((core::stringc(left)));
ret += right;
return ret;
}
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const unsigned short left, const ustring16<TAlloc>& right)
{
- ustring16<TAlloc> ret(core::stringc(left));
+ ustring16<TAlloc> ret((core::stringc(left)));
ret += right;
return ret;
}
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const int left, const ustring16<TAlloc>& right)
{
- ustring16<TAlloc> ret(core::stringc(left));
+ ustring16<TAlloc> ret((core::stringc(left)));
ret += right;
return ret;
}
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const unsigned int left, const ustring16<TAlloc>& right)
{
- ustring16<TAlloc> ret(core::stringc(left));
+ ustring16<TAlloc> ret((core::stringc(left)));
ret += right;
return ret;
}
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const long left, const ustring16<TAlloc>& right)
{
- ustring16<TAlloc> ret(core::stringc(left));
+ ustring16<TAlloc> ret((core::stringc(left)));
ret += right;
return ret;
}
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const unsigned long left, const ustring16<TAlloc>& right)
{
- ustring16<TAlloc> ret(core::stringc(left));
+ ustring16<TAlloc> ret((core::stringc(left)));
ret += right;
return ret;
}
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const float left, const ustring16<TAlloc>& right)
{
- ustring16<TAlloc> ret(core::stringc(left));
+ ustring16<TAlloc> ret((core::stringc(left)));
ret += right;
return ret;
}
template <typename TAlloc>
inline ustring16<TAlloc> operator+(const double left, const ustring16<TAlloc>& right)
{
- ustring16<TAlloc> ret(core::stringc(left));
+ ustring16<TAlloc> ret((core::stringc(left)));
ret += right;
return ret;
}