Unicode和ASCII支持 [英] Unicode and ASCII support

查看:152
本文介绍了Unicode和ASCII支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

今天我有更多的写作风格"问题:

我上课时应该指定

Hello once again,

Today I have more "writing style" question:

When I have class, should I specify

<br />
<pre>#ifdef UNICODE<br />
#define CClass CClassW<br />
#else<br />
#define CClass CClassA<br />
#endif </pre><br />


并创建两个相同类的版本?
还是在类中定义数据类型?
喜欢:


and create two versions of same class?
Or rather define the data types inside the class?
Like:

#ifdef UNICODE
CMap<CString, LPCWSTR, DWORD, DWORD> m_SomeMap;
#else
CMap<CString, LPCSTR, DWORD, DWORD> m_SomeMap;
#endif 



感谢所有建议,

谢谢



Appreciate all advices,

Thanks

推荐答案

为unicode和non-unicode创建不同的类名称是没有道理的.

在这里真正重要的是字符串数据类型.
因此,您的CMap示例很有意义,因为它包含一个字符指针.
您最好使用-
CMap<CString, LPCTSTR, DWORD, DWORD> m_SomeMap;


LPCTSTR转换为LPCSTRLPCWSTR,具体取决于是否定义了UNICODE.

我个人建议始终使用宽版本的字符串,因为Windows在内部使用这些字符串,也因为您有时会需要它们.
Creating different names of classes for unicode and non-unicode doesn''t make sense.

It''s the string data type that really matters here.
So your CMap example makes sense because it contains a character pointer.
You might as well use -
CMap<CString, LPCTSTR, DWORD, DWORD> m_SomeMap;


LPCTSTR translates to LPCSTR or LPCWSTR depending on whether UNICODE is defined or not.

I would personally recommend always using the wide version of strings because Windows internally uses these and also because you''re going to need them somewhere sometime.


这篇关于Unicode和ASCII支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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