是TCHAR还有用吗?

编程入门 行业动态 更新时间:2024-10-13 02:18:05
本文介绍了是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还有用吗?

本文发布于:2023-11-07 00:15:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565037.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有用吗   TCHAR

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!