当前位置: 技术问答>linux和unix
如何在UNIX下将GB转换成UNICODE
来源: 互联网 发布时间:2015-01-30
本文导语: 我在NT下用下面的代码测试通过,为什么在UNIX下就转换不成功?希望各位观众给我个理由好吗?谢过先了。。! #include "stdio.h" #include "stdlib.h" #include "string.h" #include "locale.h" int covertmtw(char *srcstr,char *deststr) { int r...
我在NT下用下面的代码测试通过,为什么在UNIX下就转换不成功?希望各位观众给我个理由好吗?谢过先了。。!
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "locale.h"
int covertmtw(char *srcstr,char *deststr)
{
int ret;
ret=strlen(srcstr);
ret=mbstowcs((wchar_t*)deststr,srcstr,ret);
return ret;
}
int covertwtm(char *srcstr,char *deststr)
{
int ret=0;
ret=strlen(srcstr);
ret=wcstombs(deststr,(wchar_t*)srcstr,ret);
return ret;
}
void main()
{
char mbuf[128]={NULL};
char wbuf[128]={NULL};
int i=0,len=0;
int ret=-1;
memset(mbuf,0,sizeof(mbuf));
memset(wbuf,0,sizeof(wbuf));
strcpy(mbuf,"中国");
len=strlen(mbuf);
for(i=0;i
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "locale.h"
int covertmtw(char *srcstr,char *deststr)
{
int ret;
ret=strlen(srcstr);
ret=mbstowcs((wchar_t*)deststr,srcstr,ret);
return ret;
}
int covertwtm(char *srcstr,char *deststr)
{
int ret=0;
ret=strlen(srcstr);
ret=wcstombs(deststr,(wchar_t*)srcstr,ret);
return ret;
}
void main()
{
char mbuf[128]={NULL};
char wbuf[128]={NULL};
int i=0,len=0;
int ret=-1;
memset(mbuf,0,sizeof(mbuf));
memset(wbuf,0,sizeof(wbuf));
strcpy(mbuf,"中国");
len=strlen(mbuf);
for(i=0;i