tags:

views:

58

answers:

2

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?

A: 

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.

Jess
Although that is just the default, you can turn the option off to retain compatibility with your legacy code.
the_mandrill
Certainly! In in our case, it was just easier to recompile them. We knew we were going to continue to develop new solutions against them, and rather than turn it off in all newly developed solutions, we just decided to recompile the old. I was just trying to point out something to look out for.
Jess
Thanks for the input Jess
Brian T Hannan
A: 

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.

Pavel Radzivilovsky
say what? that might be one of the most confusing few paragraphs I've read in a long time. what is an 8.3 filename?
Brian T Hannan
8.3 filename is something every file has under windows, as an additional name for the file. You can see them with "dir /x" command. For example, C:\Program files is also "C:\PROGRA~1" on my comp. It is important for supporting unicode in your applications, and for crating multi-platform software, because this is the only trick to do it right on windows, if you open files.
Pavel Radzivilovsky
Lyrical remark: sorry for the confusion. I am amazed how doing text can be complicated sometimes. As all things, it should be handled the simplest possible way, but no simpler. See also: http://stackoverflow.com/questions/1049947/should-utf-16-be-considered-harmful
Pavel Radzivilovsky