Ghanashyam
Fri Jan 11 00:33:59 CST 2008
I do really appreciate the reply.
Thanks.
Ghans
"Giovanni Dicanio" wrote:
>
> "Ghanashyam" <Ghanashyam@discussions.microsoft.com> ha scritto nel messaggio
> news:C2EFF567-77E3-4FE9-AB85-95B2A59A54AC@microsoft.com...
> >I have a server application written in C++ (VC++ 6.0 environment) and is
> > quite matured and serves many customers.At present it does not support
> > UNICODe and I am looking at a way to make it Unicode compatible.Code base
> > is
> > quite large.
> > What is the best way to proceed with ?
>
> Mihai wrote a very useful page on his web site about enabling VC++6 projects
> for Unicode:
>
>
http://www.mihai-nita.net/article.php?artID=20060723a
>
> if you use TCHARs and CString and _T() decorator for string literals in your
> source code, you should have no problem in rebuilding your project in
> Unicode.
>
> However, you should pay attention to some subtle things.
>
> e.g. suppose that you need the size of a string buffer (for some Win32 API
> function). If you have an array of char's in current ANSI status, and you
> use sizeof(), you are OK (1 char = 1 byte). But if you switch to Unicode,
> you can't use sizeof(), you should use __countof() instead, beacuse several
> Win32 API functions expect the size of the array in TCHARs (not in bytes).
> [1]
> And __countof() is kind of (sizeof(array)/sizeof(array[0])), [2] i.e. it
> returns the count of TCHARs.
>
> You may also consider to move your code to a more modern compiler, like
> Visual C++ of Visual Studio 2008 (you get better safety, better C++
> compiler, and also better Unicode support).
>
> [1] There are also Win32 functions like StringCbCopy (identified by the "Cb"
> substring) that works well with sizeof(), because they need the size in
> *bytes* (not in TCHARs).
>
> [2] The actual implementation of __countof is smarter than what I wrote, in
> fact it uses C++ templates in an advanced mode, to prevent passing a pointer
> instead of a whole array (if you pass a pointer to __countof, you get a
> compile-time error).
>
>
> Giovanni
>
>
>