是TCHAR还有用吗? [英] Is TCHAR still relevant?

查看:90
本文介绍了是TCHAR还有用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Windows编程和读的书彼佐尔德我不知道以后:

I'm new to Windows programming and after reading the Petzold book I wonder:

它仍然是很好的做法,使用 TCHAR 键入和 _T()函数来声明字符串,或者我应该只使用了 wchar_t的 L在新的code字符串?

is it still good practice to use the TCHAR type and the _T() function to declare strings or if I should just use the wchar_t and L"" strings in new code?

我将只针对Windows 2000和了,我的code将国际化从一开始的。

I will target only Windows 2000 and up and my code will be i18n from the start up.

推荐答案

我仍然会使用TCHAR语法如果我今天在做一个新项目。这里没有使用它和WCHAR语法之间没有太大实际差别,我preFER code这是字符类型是明确的。由于大多数API函数和助手对象采取/使用TCHAR类型(例如:CString的),是很有道理的使用它。再加上它给你的灵活性,如果你决定使用code在ASCII程序在某些时候,或者Windows曾经发展到统一code32等。

I would still use the TCHAR syntax if I was doing a new project today. There's not much practical difference between using it and the WCHAR syntax, and I prefer code which is explicit in what the character type is. Since most API functions and helper objects take/use TCHAR types (e.g.: CString), it just makes sense to use it. Plus it gives you flexibility if you decide to use the code in an ASCII app at some point, or if Windows ever evolves to Unicode32, etc.

如果你决定去的路线WCHAR,我会很明确了。也就是说,使用CStringW代替CString的,和铸造宏转换为TCHAR时。(如:CW2CT)

If you decide to go the WCHAR route, I would be explicit about it. That is, use CStringW instead of CString, and casting macros when converting to TCHAR (eg: CW2CT).

这是我的意见,无论如何。

That's my opinion, anyway.

这篇关于是TCHAR还有用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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