Index: text.c =================================================================== RCS file: /cvsroot/wv/text.c,v retrieving revision 1.53 diff -u -r1.53 text.c --- text.c 2000/11/14 23:29:33 1.53 +++ text.c 2000/11/16 00:14:11 @@ -188,6 +188,8 @@ } /*********************************************************************************************/ +#ifdef WV_SWAP_ICONV + /** * This next bit of code is messy * Basically, iconv's byte order got changed on RH7 @@ -221,7 +223,7 @@ static U16 try_UToC(U16 c, iconv_t iconv_handle) { - char ibuf[2],obuf[10]; + char ibuf[2], obuf[10]; size_t ibuflen = sizeof(ibuf), obuflen=sizeof(obuf); const char* iptr = ibuf; char* optr = obuf; @@ -261,19 +263,26 @@ return ret; } -static int swap_iconv_u2n_always(iconv_t handle) +static int swap_iconv_u2n_always(const char *encname) { - return UToNative(0x20, handle) != 0x20; + iconv_t handle = NULL; + int rtn = 0; + + handle = iconv_open(encname, "UCS-2"); + rtn = UToNative(0x20, handle) != 0x20; + + iconv_close(handle); + return rtn; } -static int swap_iconv_u2n(iconv_t handle, U16 lid) +static int swap_iconv_u2n(U16 lid) { static int last_lid = -1; int rtn = -1; if(lid != last_lid) { - rtn = swap_iconv_u2n_always(handle); + rtn = swap_iconv_u2n_always(wvLIDToCodePageConverter(lid)); last_lid = lid; wvTrace(("DOM: swapping iconv byte order: (%d, %d)\n", rtn, lid)); } @@ -281,6 +290,8 @@ return rtn; } +#endif /* WV_SWAP_ICONV */ + /*********************************************************************************************/ U16 wvHandleCodePage(U16 eachchar, U16 lid) @@ -335,7 +346,8 @@ p = obuf; wv_iconv(iconv_handle, &ibuf, &ibuflen, &obuf, &obuflen); - if(!swap_iconv_u2n(iconv_handle, lid)) +#ifdef WV_SWAP_ICONV + if(swap_iconv_u2n(lid)) { eachchar = (U8)*p++; eachchar = (eachchar << 8)&0xFF00; @@ -343,14 +355,16 @@ } else { - eachchar = (U8)*(p+1); - eachchar = (eachchar << 8)&0xFF00; - eachchar += (U8)*p; + eachchar = (U8)*(p+1); + eachchar = (eachchar << 8)&0xFF00; + eachchar += (U8)*p; } - +#else + eachchar = (U16)*p; +#endif /* WV_SWAP_ICONV */ iconv_close(iconv_handle); return(eachchar); - } + } void wvOutputFromUnicode(U16 eachchar,char *outputtype) { @@ -398,9 +412,8 @@ p = obuf; len = obuflen; - /* TODO: change this to swap_iconv_n2u() */ - if(swap_iconv_u2n_always(iconv_handle)) + if(0) { char temp = *ibuf; *ibuf = *(ibuf+1);