本文介绍了WideCharToMultiByte()vs. wcstombs()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WideCharToMultiByte()和wcstombs()之间有什么区别
何时使用哪个?

What is the difference between WideCharToMultiByte() and wcstombs()When to use which one?

推荐答案

简单来说: WideCharToMultiByte 函数暴露参数列表中用于转换的编码/代码页,而 wcstombs 才不是。这是一个主要的PITA,作为标准什么编码用于产生 wchar_t ,而你作为一个开发人员当然需要知道你正在转换/从哪个编码。

In a nutshell: the WideCharToMultiByte function exposes the encodings/code pages used for the conversion in the parameter list, while wcstombs does not. This is a major PITA, as the standard does not define what encoding is to be used to produce the wchar_t, while you as a developer certainly need to know what encoding you are converting to/from.

WideCharToMultiByte 当然是Windows API函数,不能在任何其他平台上使用。

Apart from that, WideCharToMultiByte is of course a Windows API function and is not available on any other platform.

如果你的应用程序没有专门写成可移植到非Windows操作系统,使用 WideCharToMultiByte 。否则,您可能需要使用。

Therefore I would suggest using WideCharToMultiByte without a moment's thought if your application is not specifically written to be portable to non-Windows OSes. Otherwise, you might want to wrestle with wcstombs or (preferably IMHO) look into using a full-feature portable Unicode library such as ICU.

这篇关于WideCharToMultiByte()vs. wcstombs()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-04 10:34