免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3191 | 回复: 0
打印 上一主题 下一主题

请教iconv报错[not enough space] [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-28 11:05 |只看该作者 |倒序浏览
#include <iconv.h>
#include <stdio.h>
#include <locale.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <strings.h>

int main(int argc, char * argv[])
{
    int ret;

    char *str = (char*)malloc(10);

    int src_len;
    int dest_len;
    char *dest;
    iconv_t conv, conv2;

    strcpy(str, \"test\");

    src_len = strlen(str)+ 1;
    dest_len = 1000;

    dest = (char*)malloc(dest_len);
    bzero(dest, dest_len);

    conv = iconv_open(\"ISO-8859-1\", \"UTF-8\");
    if (conv == (iconv_t)-1) {
        printf(\"iconv_open: errno[%d]msg[%s]\\n\", errno, strerror(errno));
        return -1;
    }

    ret = iconv(conv, (char**)&str, &src_len, &dest, &dest_len);
    if (ret == -1) {
        printf(\"iconv: [%d][%s]\\n\", errno, strerror(errno));
        return -1;
    }

    printf(\"%s - %S\\n\", str, dest);
    iconv_close(conv);
    free(dest);
    free(str);

    return 0;
}


执行结果iconv: [12][Not enough space]
请问什么原因啊?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP