设置字符集:-Unicode/多字节字符集 [英] Setting Character set : - Unicode / Multibyte charecter set

查看:115
本文介绍了设置字符集:-Unicode/多字节字符集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我的"Windows窗体应用程序项目"下有两个.cpp文件,分别是a.cpp和b.cpp.我的项目属性->配置->常规->字符集=多字节字符支持"中的字符集.
现在对于a.cpp我想要多字节字符支持"(通过proj prop实现)
对于b.cpp,我想要"Unicode字符支持"

Hello,
I have two .cpp files under my "Windows Form Application project" say a.cpp and b.cpp . Character set in my "project prop->configuration->general->charecter set= Multibyte char support".
Now for a.cpp i want "Multibyte char support" (which is achieved from proj prop)
and for b.cpp i want "Unicode char support"
How can do both things simulteneously?

推荐答案

在做一个同时处理ANSI和Unicode的混合"应用程序时,要记住两件事. br/>
1.数据类型-通常,您将要使用TCHAR,LPCTSTR等.但是,当您要处理ANSI时,可以切换为使用char.

2.函数-对于TCHAR数据,使用相应的TCHAR函数:strlen-> _tcslen等.某些Win32 API也有两个版本,A和W; A和W.示例:GetFileAttributesA(),GetFileAttributesW().

只要将这两件事直接放在代码中,就应该没有问题.
There are two things to keep in mind when you are doing a "hybrid" app that deals with both ANSI and Unicode.

1. The data type - typically, you would want to use TCHAR, LPCTSTR, etc. But when you want to deal with ANSI, you can switch to using char.

2. The functions - for TCHAR data, use the the corresponding TCHAR functions: strlen --> _tcslen, etc. Some of the Win32 APIs also have two versions, A and W; example: GetFileAttributesA(), GetFileAttributesW().

As long as you keep these two things straight in your code, you should have no problems.


这篇关于设置字符集:-Unicode/多字节字符集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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