UTF-8 <==> unicode(WCHAR)
static int fetchWordFromUTF8(const chConstStringA& strText, WCHAR& result)
{
int nLength = strText.length();
if(nLength <= ) return ; LPCSTR lpszTextA = strText.c_ptr();
BYTE byte = *lpszTextA;
if ((byte >> ) == 0x00)
{
result = (WCHAR)(BYTE)*lpszTextA;
return ;
}
else if ((byte >> ) == 0x06)
{
if(nLength >= )
{
DWORD dw0 = (DWORD)(BYTE)lpszTextA[];
DWORD dw1 = (DWORD)(BYTE)lpszTextA[];
result = (WCHAR)((dw1&0x3F) | ((dw0&0x1F) << ));
return ;
}
}
else if ((byte >> ) == 0x0E)
{
if(nLength >= )
{
DWORD dw0 = (DWORD)(BYTE)lpszTextA[];
DWORD dw1 = (DWORD)(BYTE)lpszTextA[];
DWORD dw2 = (DWORD)(BYTE)lpszTextA[];
result = (WCHAR)((dw2&0x3F) | ((dw1&0x3F) << ) | ((dw0&0x0F)<<));
return ;
}
}
result = '?';
return ;
} static int fetchUTF8FromWord(const UINT& word, LPSTR szResult)
{
if (word < 0x0080)
{
szResult[] = (ACHAR)word;
return ;
}
else if (word < 0x0800)
{
szResult[] = (ACHAR)(0xC0 | (BYTE)(word>>));
szResult[] = (ACHAR)(0x80 | (BYTE)(word&0x003F));
return ;
}
else// if (word <= 0xFFFF)
{
szResult[] = (ACHAR)(0xE0 | (BYTE)(word>>));
szResult[] = (ACHAR)(0x80 | (BYTE)((word>>) & 0x3F));
szResult[] = (ACHAR)(0x80 | (BYTE)(word&0x3F));
return ;
}
szResult[] = '?';
return ;
}
UTF-8 <==> unicode(WCHAR)的更多相关文章
- Unicode 与 Unicode Transformation Format(UTF,UTF-8 / UTF-16 / UTF-32)
ASCII(American Standard Code for Information Interchange):早期它使用7 bits来表示一个字符,总共表示27 = 128个字符:后来扩展到8 ...
- Unicode和UTF的关系
目录结构: contents structure [+] 什么是USC UCS的编码方式 Unicode的来源 为什么需要Unicode Unicode的方式 Unicode和UTF UTF和Unic ...
- ASCII UNICODE UTF "口水文"
最近接了一个单是需要把非 UTF-8 (No BOM)编码的文件转换成 UTF-8 (No BOM),若此文件是 UTF-8 但带有 BOM ,需要转换成不带 BOM 的.于是开启了一天的阅读.首先花 ...
- 转:Unicode字符集和多字节字符集关系
原文地址: http://my.oschina.net/alphajay/blog/5691 unicode.ucs-2.ucs-4.utf-16.utf-32.utf-8 http://stallm ...
- Unicode字符集和多字节字符集关系
在计算机中字符通常并不是保存为图像,每个字符都是使用一个编码来表示的,而每个字符究竟使用哪个编码代表,要取决于使用哪个字符集(charset). 在最初的时候,Internet上只有一种字符集—— ...
- Unicode和多字节字符集
今天自己写的发现一个输出路径程序使用unicode字符集只能输出单个的首字符,问了一下同事,改为使用多字节字符集,问题解决了 于是上网看了他们的区别: 很多没看完,但起码了解到字符集的演变过程, 转 ...
- 【转】【编码】ASCII 、UNICODE和UTF-8之二
字符发展 1. 美国 ASCII-(American standard code information interchange) 美国信息互换标准代码 范围:1-127 ; 单字 备注:前部用作控制 ...
- 转: 带你玩转Visual Studio——带你理解多字节编码与Unicode码
上一篇文章带你玩转Visual Studio——带你跳出坑爹的Runtime Library坑帮我们理解了Windows中的各种类型C/C++运行时库及它的来龙去脉,这是C++开发中特别容易误入歧途的 ...
- Unicode、UTF-8、UTF-16和UTF-32的区别
Unicode是一个巨大的字符集,给世界上所有的字符定义了一个唯一编码.其仅仅规定了每个符号的二进制代码,没有制定细化的存储规则.UTF-8.UTF-16.UTF-32才是Unicode的存储格式定义 ...
随机推荐
- Oracle11g的delayed failed logins特性引起的性能问题
用户反映修改密码后程序明显变慢,查看AWR发现: ASH信息如下: 进一步验证: SQL>select event,p1 from v$session t where t.username is ...
- python数据分析之pandas库的DataFrame应用一
DataFrame是一个表格型的数据结构,它含有一组有序的列,每列可以是不同的值类型(数值,字符串,布尔型).DateFrame既有行索引也有列索引,可以被看作为由Series组成的字典. 构建Dat ...
- Android 百度地图的使用
可以参考百度官网Android开发指南. 里面有详细的步骤和Sample例子. http://lbsyun.baidu.com/index.php?title=androidsdk/guide/int ...
- [转]centos 下 autoconf版本升级
首先查看当前版本 #rpm -qf /usr/bin/autoconf autoconf-2.63-5.1.el6.noarch 卸载当前版本 rpm -e --nodeps autoconf-2.6 ...
- WCF: 没有终结点在侦听可以接受消息的 这通常是由于不正确的地址或者 SOAP 操作导致的。
问题: 由于我这里的wcf服务是采用“BasicHttpBinding”的方式,即安全绑定模式,客户端在引用这个服务后所生成的终结点配置(endpoint )就变成了<endpoint ...
- android学习笔记49——SQLite2
使用SQLite工具 位于Android SDK/tools-->sqlite3.exe,其是一个简单的SQLite数据库管理工具,类似于MySQL提供的命令行窗口. ..... 使用特定方法操 ...
- Install Slax on USB device (Slax U 盘安装)
Slax is a modern, portable, small and fast Linux operating system with a modular approach and outsta ...
- JAVA_Java常用核心包(概念)
20150802 Created By BaoXinjian
- SpringMVC 中获取所有的路由配置。
ApplicationContext context = TMSContextLookup.getApplicationContext(); String[] controllerList = con ...
- Javascript Promise对象学习
ES6中的Promise对象 var p = new Promise(function(resolve, reject){ window.setTimeout(function(){ console. ...