TranslateLanguage.h
资源名称:Language.rar [点击查看]
上传用户:yangacai01
上传日期:2020-10-06
资源大小:1730k
文件大小:1k
源码类别:
多国语言处理
开发平台:
Visual C++
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "Big5ToGb2312.h"
- void language_intial()
- {
- memset(Big5ToGb2312,0,sizeof(Big5ToGb2312));
- memset(Gb2312ToBig5,0,sizeof(Gb2312ToBig5));
- for(int i=0;i<Big5ToGb2312DataLen;i+=4)
- {
- unsigned short ii=Big5ToGb2312Data[i+1]<<8|Big5ToGb2312Data[i+0];
- unsigned short jj=Big5ToGb2312Data[i+3]<<8|Big5ToGb2312Data[i+2];
- Big5ToGb2312[ii]=jj;
- Gb2312ToBig5[jj]=ii;
- }
- }
- int language_big5_to_gbk2312(char *szBuf)
- {
- int i=0,len=strlen(szBuf);
- while(i+1<len)
- {
- unsigned short ii=(unsigned char)szBuf[i];
- ii=ii<<8|((unsigned char)szBuf[i+1]);
- unsigned short jj=Big5ToGb2312[ii];
- if(jj) { szBuf[i]=(char)(jj>>8); szBuf[i+1]=(char)jj; i+=2; continue; }
- i++;
- }
- return len;
- }
- int language_gbk2312_to_big5(char *szBuf)
- {
- int i=0,len=strlen(szBuf);
- while(i+1<len)
- {
- unsigned short ii=(unsigned char)szBuf[i];
- ii=ii<<8|((unsigned char)szBuf[i+1]);
- unsigned short jj=Gb2312ToBig5[ii];
- if(jj) { szBuf[i]=jj>>8&0xff; szBuf[i+1]=jj&0xff; i+=2; continue; }
- i++;
- }
- return len;
- }