Categories
不学无术

wcstombs转换中文的问题

http://blog.chinaunix.net/uid-1878979-id-2817097.html

在应用中碰到中文的字符串用wcstombs转换后,就成了NULL。查了一些一资料后,发现需要调用setlocale函数。这个是针对Unicode来说的,对于使用多国语言的时候需要使用该函数来定义语种
     setlocale(LC_ALL,””);     //设置本地默认Locale. 或者是setlocale(LC_ALL, “chs”)
wcstombs(dest, source, length);
setlocale(LC_ALL,”C”);     //默认

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.