将Char *转换为unicode eqivalent [英] Converting Char * to unicode eqivalent

查看:78
本文介绍了将Char *转换为unicode eqivalent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在将我的项目(主要是在ascii中)转换为unicode。我需要更改所有文字字符串,char数据类型和处理字符串的函数。



使用TChar.h,我将CHAR转换为TCHAR。如何关于字符*? ??



我有很多函数,其中 Char * 作为参数传递,我应该用哪种数据类型替换这是为了支持unicode。



这是CString吗?



请帮助。



问候,

Joy

Hello guys,

I am converting my project( basically in ascii) to unicode. I need to change all literal strings, char datatypes and functions that deals with strings.

Using TChar.h, I converted CHAR to TCHAR.How about Char * ????

I have many functions where Char * is passed as argument,with which datatype I should replace this to support unicode.

Is it CString??

Please help.

Regards,
Joy

推荐答案

你只需要 tchar.h TCHAR 类型,如果要生成代码的ASCII和Unicode版本。如果你这样做,那么你应该使用以下类型:

You only need tchar.h and the TCHAR type if you want to produce both ASCII and Unicode versions of your code. If you do it this way then you should use the following types:
TCHAR    character;           // a single character
TCHAR*   character_array;     // an array of characters, aka string
PTCHAR   character_array;     // same as TCHAR*
PTSTR    character_string;    // same as PTCHAR
PCTSTR   constant_string = _T("A constant string"); // all string literals should be coded thus.



编译器将根据项目常规设置中 UNICODE 定义的设置生成正确的类型和文字。



如果您只转换为Unicode,那么您可以使用上述类型或重新定义所有宽字符并使用:


The compiler will then generate the correct types and literals based on the setting of the UNICODE define in your project General settings.

If you are converting to Unicode only, then you can use the above types or redefine to all wide characters and use:

WCHAR    character;           // a single character
WCHAR*   character_array;     // an array of characters, aka string
PWCHAR   character_array;     // same as WCHAR*
PWSTR    character_string;    // same as PWCHAR
PCWSTR   constant_string = L"A constant string"; // all string literals should be coded thus.





如果您的程序使用MFC或WTL,那么您可以使用 CString 作为替代方案。


这篇关于将Char *转换为unicode eqivalent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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