2002-02-16 Radek Doulik <rodo@ximian.com>
authorRadek Doulik <rodo@mono-cvs.ximian.com>
Sat, 16 Feb 2002 19:39:35 +0000 (19:39 -0000)
committerRadek Doulik <rodo@mono-cvs.ximian.com>
Sat, 16 Feb 2002 19:39:35 +0000 (19:39 -0000)
* unicode.c (ves_icall_iconv_new_encoder): decide on big_endian,
force big_endian to be 1 for big endian machines
(ves_icall_iconv_new_decoder): ditto

svn path=/trunk/mono/; revision=2448

mono/metadata/ChangeLog
mono/metadata/unicode.c

index 47ebb361c05c63a91ce2fe3c6f184c562c59dc10..1534f264fe981d593705272d6412725d6b198cc6 100644 (file)
@@ -1,3 +1,9 @@
+2002-02-16  Radek Doulik  <rodo@ximian.com>
+
+       * unicode.c (ves_icall_iconv_new_encoder): decide on big_endian,
+       force big_endian to be 1 for big endian machines 
+       (ves_icall_iconv_new_decoder): ditto
+
 2002-02-16  Jeffrey Stedfast  <fejj@ximian.com>
 
        * socket-io.c (convert_sockopt_level_and_name): If the system
index d651971ebe9890ecefb009994e865f036fe00f2b..e162e65d4033c42ed50d76fa5a9b02eea6388e2b 100644 (file)
@@ -154,14 +154,19 @@ ves_icall_iconv_new_encoder (MonoString *name, MonoBoolean big_endian)
        iconv_t cd;
        char *n;
 
-       // fixme: add support big_endian
+       // fixme: don't enforce big endian, support old iconv
 
        g_assert (name);
 
        n = mono_string_to_utf8 (name);
 
+       /* force big endian before class libraries are fixed */
+#if G_BYTE_ORDER != G_LITTLE_ENDIAN
+       big_endian = 1;
+#endif 
+
 #ifdef HAVE_NEW_ICONV
-       cd = iconv_open (n, "UTF-16le");
+       cd = iconv_open (n, big_endian ? "UTF-16be" : "UTF-16le");
 #else
        cd = iconv_open (n, "UTF-16");
 #endif
@@ -176,14 +181,19 @@ ves_icall_iconv_new_decoder (MonoString *name, MonoBoolean big_endian)
        iconv_t cd;
        char *n;
 
-       // fixme: add support big_endian
+       // fixme: don't enforce big endian, support old iconv
 
        g_assert (name);
 
        n = mono_string_to_utf8 (name);
 
+       /* force big endian before class libraries are fixed */
+#if G_BYTE_ORDER != G_LITTLE_ENDIAN
+       big_endian = 1;
+#endif 
+
 #ifdef HAVE_NEW_ICONV
-       cd = iconv_open ("UTF-16le", n);
+       cd = iconv_open (big_endian ? "UTF-16be" : "UTF-16le", n);
 #else
        cd = iconv_open ("UTF-16", n);
 #endif