469,929 Members | 1,386 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

converting application to UNICODE

Hello everyone and thanks in advance.

I have a multilingual application which has been built in MFC VC++ 6.0
(non-Unicode). It support English German Hungarian so far, which has been
fine. But now I need it to work on Russian computers and I realized that the
application should be converted to Unicode to work in Russian.

I am totally new to .NET so I'm not sure of this, but I read somewhere that
if converted my apllication to .NET (manages C++) and specify Encoding.UTF8
it should work???

Would this be a better approach (make it .NETtable) or shouls I convert my
existing code in VC++6.0 to convert it to Unicode ( wcscat, wcscpy etc.)

Thanks a lot
Srishti
Nov 17 '05 #1
5 2258
Hi Srishti,
I am totally new to .NET so I'm not sure of this, but I read somewhere
that if converted my apllication to .NET (manages C++) and specify
Encoding.UTF8 it should work???

Would this be a better approach (make it .NETtable) or shouls I convert my
existing code in VC++6.0 to convert it to Unicode ( wcscat, wcscpy etc.)


For the reason that the VC++.NET can not convert your MFC program to the
managed C++ program, the practical convention is migrating your current
code to Unicode-compatible code, to do this, you need to take the following
steps(digested from the <<Developing International Software>> from MS
Press):

1. Modify your code to use generic data types.
such as char, char* -> TCHAR and TCHAR*, which defined in the Win32
file WINDOWS.H, or to _TCHAR as defined in the Visual C++ file TCHAR.H.
Replace instances of LPSTR and LPCH with LPTSTR and LPTCH.

2. Modify your code to use generic function prototypes.
such as use the C run-time call _tcslen instead of strlen, and use the
Win32 API SetWindowText instead of SetWindowTextA.

3. Surround any character or string literal with the TEXT macro.
The TEXT macro conditionally places an "L" in front of a character
literal or a string literal definition.

4. Create generic versions of your data structures.
Type definitions for string or character fields in structures should
resolve correctly based on the UNICODE compile-time flag.

5. Change your build process. When you want to build a Unicode version of
your application, both the Win32 compile-time flag UNICODE and the C
run-time compile-time flag _UNICODE must be defined.

6. Adjust pointer arithmetic.
Subtracting char* values yields an answer in terms of bytes; subtracting
wchar_t* values yields an answer in terms of 16-bit chunks. When
determining the number of bytes (for example, when allocating memory for a
string), multiply the length of the string in symbols by sizeof(TCHAR).
When determining the number of characters from the number of bytes, divide
by sizeof(TCHAR).

7. Check for any code that assumes a character is always 1 byte long.
Code that assumes a character's value is always less than 256 (for
example, code that uses a character value as an index into a table of size
256) must be changed. Make sure your definition of NULL is 16 bits long.

For more detailed direction on how to migrate to Unicode Applications in
VC++, I suggest you can refer to the Chapter 3 "Unicode" of the book
<<Developing International Software>> 2nd edition.
Hope this helps!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default...sdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 17 '05 #2
Thanks Gary,
But I was also wondering how much work it would be to convert my existing
VC++6.0 application to managed C++. And if it is in managed C++would it be in
UNICODE?

Regards
Srishti

"Gary Chang[MSFT]" wrote:
Hi Srishti,
I am totally new to .NET so I'm not sure of this, but I read somewhere
that if converted my apllication to .NET (manages C++) and specify
Encoding.UTF8 it should work???

Would this be a better approach (make it .NETtable) or shouls I convert my
existing code in VC++6.0 to convert it to Unicode ( wcscat, wcscpy etc.)


For the reason that the VC++.NET can not convert your MFC program to the
managed C++ program, the practical convention is migrating your current
code to Unicode-compatible code, to do this, you need to take the following
steps(digested from the <<Developing International Software>> from MS
Press):

1. Modify your code to use generic data types.
such as char, char* -> TCHAR and TCHAR*, which defined in the Win32
file WINDOWS.H, or to _TCHAR as defined in the Visual C++ file TCHAR.H.
Replace instances of LPSTR and LPCH with LPTSTR and LPTCH.

2. Modify your code to use generic function prototypes.
such as use the C run-time call _tcslen instead of strlen, and use the
Win32 API SetWindowText instead of SetWindowTextA.

3. Surround any character or string literal with the TEXT macro.
The TEXT macro conditionally places an "L" in front of a character
literal or a string literal definition.

4. Create generic versions of your data structures.
Type definitions for string or character fields in structures should
resolve correctly based on the UNICODE compile-time flag.

5. Change your build process. When you want to build a Unicode version of
your application, both the Win32 compile-time flag UNICODE and the C
run-time compile-time flag _UNICODE must be defined.

6. Adjust pointer arithmetic.
Subtracting char* values yields an answer in terms of bytes; subtracting
wchar_t* values yields an answer in terms of 16-bit chunks. When
determining the number of bytes (for example, when allocating memory for a
string), multiply the length of the string in symbols by sizeof(TCHAR).
When determining the number of characters from the number of bytes, divide
by sizeof(TCHAR).

7. Check for any code that assumes a character is always 1 byte long.
Code that assumes a character's value is always less than 256 (for
example, code that uses a character value as an index into a table of size
256) must be changed. Make sure your definition of NULL is 16 bits long.

For more detailed direction on how to migrate to Unicode Applications in
VC++, I suggest you can refer to the Chapter 3 "Unicode" of the book
<<Developing International Software>> 2nd edition.
Hope this helps!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default...sdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 17 '05 #3
Also, is it true that Unicode applications don't work on Win98/Me? Is there
any workaround. I read about Unicows.dll which provide a Unicode layer for
windows 98/me but it only works with an application in .NET ( doed that mean
managed C++, or the application is not managed just compiled in Visual
Studio.NET would work??? )

Thanks & Regard
Srishti

"Gary Chang[MSFT]" wrote:
Hi Srishti,
I am totally new to .NET so I'm not sure of this, but I read somewhere
that if converted my apllication to .NET (manages C++) and specify
Encoding.UTF8 it should work???

Would this be a better approach (make it .NETtable) or shouls I convert my
existing code in VC++6.0 to convert it to Unicode ( wcscat, wcscpy etc.)


For the reason that the VC++.NET can not convert your MFC program to the
managed C++ program, the practical convention is migrating your current
code to Unicode-compatible code, to do this, you need to take the following
steps(digested from the <<Developing International Software>> from MS
Press):

1. Modify your code to use generic data types.
such as char, char* -> TCHAR and TCHAR*, which defined in the Win32
file WINDOWS.H, or to _TCHAR as defined in the Visual C++ file TCHAR.H.
Replace instances of LPSTR and LPCH with LPTSTR and LPTCH.

2. Modify your code to use generic function prototypes.
such as use the C run-time call _tcslen instead of strlen, and use the
Win32 API SetWindowText instead of SetWindowTextA.

3. Surround any character or string literal with the TEXT macro.
The TEXT macro conditionally places an "L" in front of a character
literal or a string literal definition.

4. Create generic versions of your data structures.
Type definitions for string or character fields in structures should
resolve correctly based on the UNICODE compile-time flag.

5. Change your build process. When you want to build a Unicode version of
your application, both the Win32 compile-time flag UNICODE and the C
run-time compile-time flag _UNICODE must be defined.

6. Adjust pointer arithmetic.
Subtracting char* values yields an answer in terms of bytes; subtracting
wchar_t* values yields an answer in terms of 16-bit chunks. When
determining the number of bytes (for example, when allocating memory for a
string), multiply the length of the string in symbols by sizeof(TCHAR).
When determining the number of characters from the number of bytes, divide
by sizeof(TCHAR).

7. Check for any code that assumes a character is always 1 byte long.
Code that assumes a character's value is always less than 256 (for
example, code that uses a character value as an index into a table of size
256) must be changed. Make sure your definition of NULL is 16 bits long.

For more detailed direction on how to migrate to Unicode Applications in
VC++, I suggest you can refer to the Chapter 3 "Unicode" of the book
<<Developing International Software>> 2nd edition.
Hope this helps!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default...sdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.


Nov 17 '05 #4
>I read about Unicows.dll which provide a Unicode layer for
windows 98/me but it only works with an application in .NET ( doed that mean
managed C++, or the application is not managed just compiled in Visual
Studio.NET would work???


You can use unicows with VC6 or VC7(.1) - native code.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #5
Hi Srishti,
But I was also wondering how much work it would be to convert my existing
VC++6.0 application to managed C++.
It would be a good many work to do if you just mean you want to convert
your VC6 MFC application to a Managed C++ application, just like rewrite
the whole program, there isn't a managed version MFC.
And if it is in managed C++would it be in UNICODE?


The managed char class and string type hold the UNICODE characters and
string.
Thanks!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default...sdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Peter Wilkinson | last post: by
10 posts views Thread by Maxim Kasimov | last post: by
2 posts views Thread by Nikola Skoric | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.