iconv的一些问题

mao_pu_hua mao_pu_hua 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
utf8str = "\xCE\xD2\xD4\xCE\xB5\xB9";
这串字符串在windows下面用printg打印结果是"我晕倒",在linux是打印不出来的。我想将其转化为utf-8编码,在linux下面打印出来。下面是代码,请各位大虾看看有问题问题,谢谢,我运行时候总是打印不出来。(机器上面确定能打印utf-8编码中文)
utf8str = "\xCE\xD2\xD4\xCE\xB5\xB9";
int MAXSIZE = 1024;
int utf8len = strlen(utf8str);
printf( "utf8len = %d\n", utf8len );

iconv_t cd = iconv_open("UTF-8", "GBK");

if( cd == (iconv_t)-1 )
{
printf( "error1\n" );
return ;
}
output = malloc( 1024 );
if( iconv( cd, &utf8str,&utf8len, &output, &MAXSIZE))
{
printf( "error2\n" );
return;
}
printf( "%s\n", output );
iconv_close(cd);
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
mao_pu_hua
C语言 70,040 成员 243,237 内容