summaryrefslogtreecommitdiff
path: root/linux-x86/share/swig/ruby/std_wstring.i
diff options
context:
space:
mode:
Diffstat (limited to 'linux-x86/share/swig/ruby/std_wstring.i')
-rw-r--r--linux-x86/share/swig/ruby/std_wstring.i15
1 files changed, 13 insertions, 2 deletions
diff --git a/linux-x86/share/swig/ruby/std_wstring.i b/linux-x86/share/swig/ruby/std_wstring.i
index 2b63343..c5d168a 100644
--- a/linux-x86/share/swig/ruby/std_wstring.i
+++ b/linux-x86/share/swig/ruby/std_wstring.i
@@ -1,4 +1,15 @@
%{
+#if defined(__linux__)
+#include <endian.h>
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define SWIG_RUBY_ENDIAN "LE"
+#elif BYTE_ORDER == BIG_ENDIAN
+#define SWIG_RUBY_ENDIAN "BE"
+#endif
+#else
+#define SWIG_RUBY_ENDIAN "LE"
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -15,9 +26,9 @@ extern "C" {
#ifndef SWIG_RUBY_WSTRING_ENCODING
#if WCHAR_MAX == 0x7fff || WCHAR_MAX == 0xffff
-#define SWIG_RUBY_WSTRING_ENCODING "UTF-16LE"
+#define SWIG_RUBY_WSTRING_ENCODING "UTF-16" SWIG_RUBY_ENDIAN
#elif WCHAR_MAX == 0x7fffffff || WCHAR_MAX == 0xffffffff
-#define SWIG_RUBY_WSTRING_ENCODING "UTF-32LE"
+#define SWIG_RUBY_WSTRING_ENCODING "UTF-32" SWIG_RUBY_ENDIAN
#else
#error unsupported wchar_t size. SWIG_RUBY_WSTRING_ENCODING must be given.
#endif