would std :: basic_string< TCHAR>优于在Windows上的std :: wstring? [英] Would std::basic_string<TCHAR> be preferable to std::wstring on Windows?

查看:379
本文介绍了would std :: basic_string< TCHAR>优于在Windows上的std :: wstring?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的理解,Windows#将TCHAR定义为基于构建的应用程序的正确字符类型 - 因此在UNICODE构建中 wchar_t char

As I understand it, Windows #defines TCHAR as the correct character type for your application based on the build - so it is wchar_t in UNICODE builds and char otherwise.

因为这个原因,我想知道 std :: basic_string< TCHAR> > std :: wstring ,因为第一个在理论上将匹配应用程序的字符类型,而第二个将总是宽。

Because of this I wondered if std::basic_string<TCHAR> would be preferable to std::wstring, since the first would theoretically match the character type of the application, whereas the second would always be wide.

所以我的问题本质上是: std :: basic_string< TCHAR> > std :: wstring 在Windows上?而且,使用 std :: basic_string< TCHAR> 会有任何警告(即意外的行为或副作用)吗?或者,我应该在Windows上使用 std :: wstring 而忘记了吗?

So my question is essentially: Would std::basic_string<TCHAR> be preferable to std::wstring on Windows? And, would there be any caveats (i.e. unexpected behavior or side effects) to using std::basic_string<TCHAR>? Or, should I just use std::wstring on Windows and forget about it?

推荐答案

我相信,发布非unicode版本的应用程序(支持Win95,或保存一个KB或两个)是可取的时间已经过去了:现在你将支持的底层Windows系统将要是基于unicode的(所以使用基于字符的系统接口实际上会通过插入一个垫片层从库中复杂的代码),你是否保存任何空间都是怀疑。 Go std :: wstring ,young man! - )

I believe the time when it was advisable to release non-unicode versions of your application (to support Win95, or to save a KB or two) is long past: nowadays the underlying Windows system you'll support are going to be unicode-based (so using char-based system interfaces will actually complicate the code by interposing a shim layer from the library) and it's doubtful whether you'd save any space at all. Go std::wstring, young man!-)

这篇关于would std :: basic_string&lt; TCHAR&gt;优于在Windows上的std :: wstring?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆