473,756 Members | 7,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2553
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.UTF 8 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.UTF 8 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.UTF 8 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
10703
by: Peter Wilkinson | last post by:
Hello tlistmembers, I am using the encoding function to convert unicode to ascii. At one point this code was working just fine, however, now it has broken. I am reading a text file that has is in unicode (I am unsure of which flavour or bit depth). as I read in the file one line at a time (readlines()) it converts to ascii. Simple enough. At the same time I am copressing to bz2 with the bz2 module but that works just fine. The code...
10
8536
by: Maxim Kasimov | last post by:
there are a few questions i can find answer in manual: 1. how to define which is internal encoding of python unicode strings (UTF-8, UTF-16 ...) 2. how to convert string to UCS-2 (Python 2.2.3 on freebsd4) -- Best regards, Maxim
3
5252
by: Supratim | last post by:
Hi, For past few weeks I am working on a function that would take encoded Unicode characters from query string of http requests and then decode them back to Unicode numbers. I have full success with UTF-8 encoding but it is UTF-16 where I stumble. Can somebody help me with one of the following examples that puzzle me : %B7%C9 is UTF-16 encoded version of unicode 98DE (39134 in decimal)
8
3874
by: Alphaboomer | last post by:
I'm using the following code to retrieve a list of all the Categories used by Microsoft Outlook: sub test() Dim objWSHShell As Object Dim strCategoryList As Variant Set objWSHShell = CreateObject("WScript.Shell") strCategoryList = objWSHShell.RegRead_ ("HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Categories\MasterList")
0
2037
by: kurotsuke | last post by:
I need to convert a sequence of keys presses on the keyboard into the corresponding character code (UNICODE). I'm intercepting the KeyUp event (using an external hooking library) and need to get the corrisponding code, according to the user keyboard. For example, if the user pressed SHIFT+a I need to get the 65 code I'd also need to the the opposite thing, that is converting the character UNICODE code to a sequence of key presses.
2
3546
by: Gidi | last post by:
Hi, I'm writing a C# win application program, and i need to transfer my hebrew letters from unicode to ascii, now if i use the ascii encoding it writes me ??? instead of the hebrew letter i've entered. I know what the Ascii value of each letter, so i understood that i can transfer my string to BYTE and enter the ascii value by myself. if someone has a better idea, i'll be happy to hear about it. how can i know the Unicode value of a...
2
6643
by: Paolo | last post by:
I imported a VC++6.0 project into VC++7.1. The conversion operation makes a mess with Preprocessor Definitions, adding a "$(NoInherit)" for each file. For example: I had a DLL project in VC++6.0 where the definitions were: _UNICODE,_DEBUG,_WIN32_DCOM,WIN32,_WINDOWS,_WINDLL,_AFXDLL,_USRDLL In VC++7.1, these are the preprocessor definitions of the project (right-click the project in Solution Explorer and choose Properties -> C++ ->...
1
8326
by: yashgt | last post by:
Hi, We have stored proc name proc_test(str nvarchar(30)). So far this proc has been invoked from a .NET application assuming that only English character strings will be passed to it. The calls are like proc_test('XYZ') We now have a requirement for passing Chinese strings as well. Rather than changing the calls throughout the application, we would like to handle it in the stored procedure so that it treats the string as a unicode...
2
5385
by: Nikola Skoric | last post by:
What I have is a bunch of text in arabic, and series of Unicode bytes which represent those arabic words (like this: \'c2\'e4\'f6\'d3\'f3\'c9 \'f1). Now I have to figure out how to convert my arabic text to bunch of \'somethings. If I understood Unicode correctly (and I'm not sure if I did), I first have to figure out which encoding this is (UTF-16 or UTF-32 or some other) and then convert the letters to their byte representation. I think...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.