且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

转换为Unicode(C ++,Microsoft,UTF-16,Native Windows)

更新时间:2023-11-24 21:10:04

以下是转换时需要采取的大多数阶段旧项目(定义为

Here are most of the stages you need to take when converting an old project (defined as
Use Multi-Byte Character Set






or

Not Set


项目中的
- >属性 - >常规 - >字符集。



首先将此属性设置为 Unicode



1.你好生病然后必须将任何硬编码的字符串从字符串更改为L字符串/ _T(字符串)。

2.在某些地方需要使用UNICODE,你将拥有替换:


in Project -> Properties -> General -> Character Set.

First you set this attribute to Unicode.

1. You will then have to change any hardcoded string to from "string" into L"string" / _T("string").
2. In some of the places UNICODE need to be used, you will have to replace :

char something[];



进入


into

wchar_t something[];



3.对于这些UNICODE字符串,您必须将字符串操作函数更改为其UNICODE等效字符串。例如,而不是:


3. For these UNICODE strings, you will have to change string manipulation functions into their UNICODE equivalent. For example, instead of:

strcpy(str1,str2);

使用

use

wcscpy(str1,str2);

而不是

and instead of

strcmp(str1,"")

使用

use

wcscmp(str1,_T(""))

等等...

如果你不确定,请注意,如果你谷歌例如:

and so on...
If you are not sure, please note that if you google for example:
"

strcpy unicode



你将进入MSDN页面,其中显示了旧函数的UNICODE等价物。



参考文献:



Unicode编程摘要



strcpy,wcscpy,_mbscpy