免费注册 查看新帖 |

Chinaunix

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

[其它] ARM9 开发板上 不能locale ,还有怎么查支持的字符集 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-09-23 19:36 |显示全部楼层 |倒序浏览
RT,请教各位大神

论坛徽章:
0
2 [报告]
发表于 2013-09-23 19:37 |显示全部楼层
或者怎么安装 locale

论坛徽章:
0
3 [报告]
发表于 2013-09-23 20:55 |显示全部楼层
对 我的函数里用的也是iconv 可是出现iconv_open error: Invalid argument

我认为是板子里没有我要的字符集,所以我要用locale 命令看下里有没有我要的字符集

或者版主你有没有其它办法看板子支持的字符集

谢谢版主回复 3# T-Bagwell


   

论坛徽章:
0
4 [报告]
发表于 2013-09-23 21:47 |显示全部楼层
好的 为什么我用iconv 从GBK到UTF-8 出现 Invalid argument

从GBK到UNICODE也出现Invalid argument

而从GBK到UTF-16却可以

iconv 对这些都支持啊回复 5# T-Bagwell


   

论坛徽章:
0
5 [报告]
发表于 2013-09-23 22:05 |显示全部楼层
那得从哪开始解决啊回复 7# T-Bagwell


   

论坛徽章:
0
6 [报告]
发表于 2013-09-24 18:19 |显示全部楼层
百度了下
iconv_open() 函数
如下值得一提的错误可能发生:
EINVAL
实现不支持

发现竟然不能支持字符从 fromcode 到 tocode 的转换。
可奇怪的是我iconv -l
有UCS-2,
  UCS-2BE, UCS-2LE, UCS-4, UCS-4BE, UCS-4LE, UCS2, UCS4, UHC, UJIS, UK,
  UNICODE, UNICODEBIG, UNICODELITTLE, US-ASCII, US, UTF-7, UTF-8, UTF-16,
  UTF-16BE, UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, UTF7, UTF8, UTF16,

这会是什么问题呢

回复 9# T-Bagwell


   

论坛徽章:
0
7 [报告]
发表于 2013-09-25 16:09 |显示全部楼层
char* mes_pdu()
{
char inbuf[BUFLEN]="你好!";
char outbuf[BUFLEN];
char buf[BUFLEN];
char* pin = inbuf;
char* pout = outbuf;
  printf("%s\n", inbuf);
//打开文件,读入GB2312数据到inbuf,数据长度为 len
int inleft = strlen(inbuf);
int outleft = BUFLEN;
int i;
int retsize;
iconv_t cd;
cd = iconv_open("UNICODE", "gb2312";


if (errno == EINVAL) {
                     /*EINVAL
                         实现不支持从 fromcode 到 tocode 的转换。
                    * Incomplete character or shift sequence
                      */
          printf("unsuport\n";
                     /*
                      * Outputs converted characters
                      */}
                      else
                               printf("nothing\n";
        if((iconv_t)-1 == cd) {
     perror("iconv_open error";
}

bzero(outbuf,BUFLEN);
retsize = iconv(cd, &pin, (size_t *)&inleft, &pout, (size_t *)&outleft);
if((size_t)-1 == retsize) {
     perror("iconv error";   
}
        if (retsize==-1)
        printf("retsize=-1\n";


  // for(i=0;i<=40;i++)
// printf("%x\n", outbuf);
// getchar();
   
char *tmp,*tmp2;
char tmp0[BUFLEN];

bzero(tmp0,BUFLEN);

if (NULL == (tmp2=(char *) malloc (140)) )
                                                   {
                                                    perror("error...";
                                                    exit(1);
                                                   }
if (NULL == (tmp=(char *) malloc (140)) )
                                                   {
                                                    perror("error...";
                                                    exit(1);
                                                   }
                                                  
        memcpy(tmp0,outbuf+2,BUFLEN-outleft);
       
       
         printf("%d\n", strlen(tmp0));
         
                 printf("=+++++++++++++++++++++=\n";
         for(i=0;i<=40;i++)
         
   printf("%x\n", tmp0);
  
getchar();
        int        count=0;                //表示输入了多少字符  
         
for(i = 0;i <=30
{      
          if(tmp0==0&&tmp0[i+1]==0)
                          
          count+=0;
                 else
                {
                    count++;
           tmp[i+1] =tmp0;      
           tmp = tmp0[i + 1];
          }
      
        i=i+2;
}   //两两换


  printf("=+++++++++++++++++++++=\n");
printf("%d\n", count);
  
printf("=+++++++++++++++++++++=\n");

for(i=0;i<=count*2;i++)
   printf("%x\n", tmp);

memcpy(tmp2,tmp,count*2);printf("=+++++++++++++++++++++=\n");

  for(i=0;i<=count*2;i++)
   printf("%x\n", tmp2);

free(tmp);
tmp = NULL;
iconv_close(cd);
return tmp2;
}回复 11# T-Bagwell


   

论坛徽章:
0
8 [报告]
发表于 2013-09-25 22:14 |显示全部楼层
谢谢!!

宿主机上能正常iconv了

可是放在板子上还是不行

你看我这样
./configure --prefix=/home/xyongkun/libiconv/output --host=arm-linux cc=/opt/arm-2009q1/bin/arm-none-linux-gnueabi-gcc
make
make install
是能生成板子上运行的库吗





回复 13# T-Bagwell


   

论坛徽章:
0
9 [报告]
发表于 2013-09-27 16:40 |显示全部楼层
在宿主机上用静态库 可以运行
可是交叉编译 到板子上又不行了   


我想问下你  板子上/bin没有iconv命令嘛
我要怎么弄才有 具体怎么弄 给点思路  
谢谢
回复 15# T-Bagwell


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP