Unicode
来源:互联网 发布:dhcp服务器需要mac 编辑:程序博客网 时间:2024/06/06 21:02
在MSDN中,关于函数中字符串长度参数,有这么一段描述:
When a function has a length parameter for a character string, the length should be documented as a count of TCHAR values in the string. This data type refers to bytes for Windows code page versions of the function or 16-bit words for Unicode versions. However, functions that require or return pointers to untyped memory blocks, such as theGlobalAlloc function, generally take a size in bytes, regardless of the prototype that is used. If the allocation of untyped memory is for a string, the application must multiply the number of characters by sizeof(TCHAR). PS:搜索关键词 为 Conventions for Function Prototypes
这段描述是说,当一个函数的参数指的是字符串长度时,这个长度指的是该字符串中TCHAR的个数。也就是说,这个数据类型对于Windows code page版本(基本可以理解为ANSI,但略有不同)是byte的个数,对于Unicode版本是word(16bit)的个数。但是,对于那些需要或返回指向无类型内存块的指针的函数,例如GlobalAlloc,通常指的就是byte的个数了,而无须去理会原型是什么。如果无类型内存是为一个string分配的,那么,在分配的时候,空间的大小是(等于)string字符数目乘以TCHAR的大小。
WideCharToMultiByte:从Unicode到多字节可能存在部分字符的丢失,因为多字节的字符谱是Unicode字符谱的子集。
用该函数进行转换,可以首先用该函数得到待转换的字节数,然后再用该函数进行转换。
- Unicode
- Unicode
- unicode
- Unicode
- Unicode
- Unicode
- unicode
- UNICODE
- unicode
- Unicode
- unicode
- Unicode
- Unicode
- Unicode
- Unicode
- Unicode
- Unicode
- Unicode
- Hadoop之——HDFS操作实例
- Swap Nodes in Pairs - LeetCode 24
- 设计模式
- SVN的使用
- socket阻塞与非阻塞,同步与异步、I/O模型
- Unicode
- 避免、修正程序缺陷的一些方法
- 琪露诺也能看懂的Oracle 主键值的序列自动生成与分配
- LVS+keepalive
- 两道机试题
- LeetCode | Isomorphic Strings
- 2-9-4 我的向量类
- 简单计算题:棋盘上的距离
- [LeetCode][Java] Unique Paths