wctomb bug?

"Jia Zheng (Colin)" <[email protected]>
Newsgroups gmane.os.freebsd.devel.internationalization
Message-ID <[email protected]>
Hi all,

Pardon me if this is not the right place to write.

My program uses UTF-8 internally, and I wrote the below routine to
convert a UTF-8 char using current encoding.

 24 int utf8tomb (pchar_t pcmb, const pchar_t pc)
 25 {
 26     wchar_t wc;
 27     setlocale (LC_CTYPE, "en_US.UTF-8");
 28     mbtowc (&wc, pc, MB_LEN_MAX);
 29     setlocale (LC_CTYPE, "zh_CN.GB2312");
 30     return wctomb (pcmb, wc);
 31 }

Problem: wctomb works incorrectly with zh_CN.GB2312 (in fact, any
encoding other than UTF-8 and C). When trying to convert a Chinese charactor, pcmb[0] 
always contains the decimal 17, and pcmb[1] is NULL.

Howver this routine works fine in Ubuntu. That is, pcmb points to a
string with length 2, not including the null terminator.

Besides, mbtowc works correctly. Since setlocale() was successful, I
believe the problem is with wctomb...


-zhengjia
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-i18n
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.