NO

Author Topic: Unicode compilation  (Read 3072 times)

bopdji

  • Guest
Unicode compilation
« on: October 19, 2010, 04:53:18 AM »
I am very new to C.  I am looking at a very nice working development language with a lot of examples and they have given me compiled binaries using Borland 5.5.
Everything works fine in ASCII.
I can also compile further to create executables of my program using Borland 5.5
They tell me that the software is Unicode ready.  I only have to compile either using Pelles compiler or using MVC.
I am told to "just define Unicode" and you will be able to use Unicode.
Q. 1.  Should I recompile the binaries using Pelles first?  It is an Open software and the source is there.  where and how do I put the code to activate Unicode.  Please give me the exact directions.
Q. 2. After creating the new binaries, where do i put my Unicode activation in the Program i write in and how?

Many thanks ahead of time.

CommonTater

  • Guest
Re: Unicode compilation
« Reply #1 on: October 19, 2010, 07:57:53 AM »
First I would make sure it compiles as ascii... on PellesC... You want to be sure you're dealing with conversion problems not compile problems.  You should import the code to PellesC set up projects etc and get it working first.

Once you're sure it's just a switch to unicode you will need to do the following...

Add  #define _UNICODE to the top of your #include lists.

If it's windows code you should also add #define UNICODE

Each literal string will have to set up as _TEXT("String") or L"String"

You will need to be watchful of string handling functions, changing to the wide versions as needed.  For example you'll need wcslen() instead of strlen().

You will also need to be guardful of your declarations.  Declare strings as _TCHAR not char.

If the original programmers have done their job properly adding the #define should do it... if not, well, BIG job, tons of compile errors.


bopdji

  • Guest
Re: Unicode compilation
« Reply #2 on: October 20, 2010, 04:36:39 AM »
Thanks a lot.  You have done a marvelous job at explaining.
I also got a "cheat sheet" from somebody, and should I need to do manual changes, i.e. if it is not Unicode ready as they claim, I have the cheat sheet to patiently make the changes.

I also appreciate your caution regarding the errors to expect.  That is the part that worries me most.  I come from Assembler experience followed by Basic and then X-base, all in ASCII, and am horrified at reading about C and the multiple crashes.

CommonTater

  • Guest
Re: Unicode compilation
« Reply #3 on: October 20, 2010, 04:49:16 AM »
Glad to help. 

Don't worry too much about the errors.  If it compiles as ascii, most of the errors will be string type errors... Expected wchar_t found char... sort of things.  Just follow the line numbers and fix as needed.

You may even enounter my all-time favorite PellesC error message...
"More than 100 errors, please improve yourself"
At which point you should raise a glass and smile... 'cause you've made the grade.