[kaffe] ByteToCharIconv/CharToByteIconv

Atsushi Nemoto anemo at mba.ocn.ne.jp
Thu Dec 11 18:35:03 PST 2003


>>>>> On Fri, 12 Dec 2003 10:01:26 +0900, Ito Kazumitsu <ito.kazumitsu at hitachi-cable.co.jp> said:
kazumitsu> Some version of iconv may treat UCS-2 as machine-dependent.
kazumitsu> But libiconv-1.9.1 definitely treats UCS-2 as big-endian
kazumitsu> although the behaviour of ucs2_mbtowc may be changed by
kazumitsu> FFFE/FEFF marks as endianness indicators.

Hmm... My environment is Debian 3.0 and RedHat 7.3 both using
glibc-2.2.5.  iconv in glibc-2.2.5 seems UCS-2 as native byteorder.

kazumitsu> Your patch makes ByteToCharIconv/CharToByteIconv much
kazumitsu> simpler, but I don't know whether using UCS-2BE or UCS-2LE
kazumitsu> is a good thing.

Do you worry about existence of UCS-2LE/UCS-2BE?  If so, how about
doing like this?

#ifdef WORDS_BIGENDIAN
    cd = iconv_open ((char *)str, "UCS-2BE");
#else
    cd = iconv_open ((char *)str, "UCS-2LE");
#endif
    if (cd == (iconv_t)-1)
        cd = iconv_open ((char *)str, "UCS-2");

---
Atsushi Nemoto




More information about the kaffe mailing list