这两个函数如何工作的?疑问列表:WideCharToMultiChar()
1、这个函数吧UNICODE转换为ANSI字符串,对么?
2、它对于UNICODDE的UTF-8/UTF-16是如何工作的?MultiCharToWideChar()
1、这个函数是实现的ANSI char到UNICODE的转换,那么结果是哪一种UNICODE编码(UTF-8/UTF-16)?一直没弄清楚这块的知识。

解决方案 »

  1.   

    Windows平台下默认的Unicode编码是UTF-16,所以上面的两个函数都是基于UFT-16的。
      

  2.   

    MultiByteToWideChar()
    ---------------------
    Maps a character string to a wide character (Unicode UTF-16) string. The character string mapped by this function is not necessarily from a multibyte character set. Note: The ANSI code pages can be different on different computers, or can be changed for a single computer, leading to data corruption. For the most consistent results, applications should use Unicode, such as UTF-8 (code page 65001) or UTF-16, instead of a specific code page, unless legacy standards or data formats prevent the use of Unicode. If use of Unicode is not possible, applications should tag the data stream with the appropriate encoding name when protocols allow it. HTML, XML, and HTTP files allow tagging, but text files do not.这个函数倒是明确说了是把一个ANSI转换为UTF-16编码。反向转换函数就没有细说了。
    WideCharToMultiByte()
    ---------------------
    Maps a wide character string to a new character string. The new character string is not necessarily from a multibyte character set. Note: The ANSI code pages can be different on different computers, or can be changed for a single computer, leading to data corruption. For the most consistent results, applications should use Unicode, such as UTF-8 (code page 65001) or UTF-16, instead of a specific code page, unless legacy standards or data formats prevent the use of Unicode. If use of Unicode is not possible, applications should tag the data stream with the appropriate encoding name when protocols allow it. HTML, XML, and HTTP files allow tagging, but text files do not.
      

  3.   

    尤其在xml文档的声明部分又可以指定tagging标明使用的encoding = utf-8/utf-16/gb2312等编码。可是保存的时候又可以存储为UTF-8/UTF-16/ANSI等。我都被搞晕了,请明白的大侠给讲讲,谢谢。
      

  4.   

    WideCharToMultiChar 有参数指定字符集的编码格式等...