Encode Unicode
来源:互联网 发布:淘宝失效宝贝 编辑:程序博客网 时间:2024/04/30 05:40
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int EncodeUCS2(unsigned char *SourceBuf,unsigned char *DestBuf)
{
int len,i,j=0;
wchar_t wcbuf[255];
setlocale(LC_ALL,"");
len = mbstowcs(wcbuf,SourceBuf,255); /* convert mutibytes string to wide charater string */
for (i=0;i<len;i++)
{
DestBuf[j++] = wcbuf[i]>>8; /* height byte */
DestBuf[j++] = wcbuf[i]&0xff; /* low byte */
}
return len*2;
}
int DecodeUCS2(unsigned char *SourceBuf,unsigned char *DestBuf,int len)
{
wchar_t wcbuf[255];
int i;
setlocale(LC_ALL,"");
for( i=0;i<len/2;i++ ) {
wcbuf[i]=SourceBuf[2*i]; // height byte
wcbuf[i]=(wcbuf[i]<<8)+SourceBuf[2*i+1]; // low byte
}
return wcstombs(DestBuf,wcbuf,len); /* convert wide charater string to mutibytes string */
}
int main()
{
unsigned char str[1024],str2[1024];
int len,i;
len=EncodeUCS2("新年快乐");
for(i=0;i<len;i++ ) printf("%02X",str[i]); printf("/n");
DecodeUCS2(str,str2,len);
puts(str2);
}
- Encode Unicode
- decode、encode、unicode解码
- unicode .decode /str.encode方法
- Unicode Python encode decode的知识点总结
- 字符编码,pyton中的encode,decode,unicode()
- python中 encode,decode,unicode,utf-8
- python中的编码问题unicode, encode, decode
- python 编码转换 unicode和encode作用
- python3 unicode bytes decode encode之间联系
- unicode,decode,encode在python的作用
- python中decode,encode跟unicode的关系(encode用法,decode用法)
- Unicode 编码 ASCII 编码 URL16 编码 Escape , Encode编码
- python的str,unicode对象的encode和decode方法
- 关于字符串的unicode和encode编码问题
- python的str,unicode对象的encode和decode方法
- python的str,unicode对象的encode和decode方法
- Python编码相关问题 Unicode UTF-8 encode() decode()
- python之分析decode、encode、unicode编码转换为汉字
- 嵌入式或LINUX相关研发面试题目
- GridView操作大全
- 行业选择
- php连接数据库并显示表内容
- 使用ASP.NET制作Wap网站注意事项
- Encode Unicode
- 我爱我家
- table 的 id 属性不被 document.getElementById支持
- 摘自 《疯狂的程序员》
- 多态的浅谈(C++版)
- 项目日志二
- 懂是为了更好的欣赏
- 编译 源文件奇怪的问题
- 详细分析 动态更新水晶报表(一个dataset多张表)