开发者

What are some areas of C++ code that could be affected by porting to Visual 2005 and changing to unicode?

开发者 https://www.devze.com 2023-01-08 21:06 出处:网络
We recently ported over legacy code to now use开发者_开发百科 Visual Studio 2005 and unicode. What are the key areas that are affected by switching to the unicode character set?My biggest nightmare o

We recently ported over legacy code to now use开发者_开发百科 Visual Studio 2005 and unicode.

What are the key areas that are affected by switching to the unicode character set?


My biggest nightmare of all while starting to support unicode (I don't like the word 'converting to unicode') is 3rd-party libraries which accept char* for filenames, and then forward these to legacy windows APIs like CreateFileA.

It is very hard to make these support unicode if you don't have the library source code, and also, this practice is perfectly good on Linux where UTF-8 is universally supported.

What my team had to do is getting 8.3 filename for every file before feeding it into these APIs. It relies on registry setting (ON by default) that prevents windows from using non-ascii chars in 8.3 filenames, and in keeping 8.3 filenames in the first place.

This does not work if the broken library creates a file, because the 8.3 filename is not known before creation. We had to trick this by creating a wrapper which would create the file, allocate the 8.3 filename and then feed it to the library.


MS changed the default setting in VS2005 for Treat WChar_t As Built in Type to "Yes" (Options/C-C++/Language). This forced us to recompile/update all of the external libraries we were linking against.

0

精彩评论

暂无评论...
验证码 换一张
取 消