Ian's Win32 Unicode and WinCE page



Introduction & BCX

Considerations & Strategy for compiling to WinCE

UnicodeLexer

Compile 'C' code from ANSI to Unicode

Compile with BCX Programs in PellesC

News

My working programs

Links to BCX Sites

StarTrak Home

DOWNLOAD LATEST: UnicodeLexerV3_1.zip - Source & exe of Unicode translator.

Note 1) There is no help file except this page.
Note 2) PellesC POCC.exe v5.08 is needed with PellesC v6 Include and Libs files is needed for Pocket PC and SmartPhone apps.

Calc.zip  - Kevin Diggens calculator demo - compiled in PellesC 5.08
This example demonstrates how easy it is to compile as Win32 ANSI, Win32 Unicode and for Pocket PC with only a couple of changes.
Changes are noted in the first part of the file along with build settings for PellesC.

Introduction:

Most modern compilers can now compile for unicode but normally you need to rewrite alot of your code to do this.

I just wanted an easier way to convert ANSI 'C' code to a compiler ready unicode format.
Back in 2004 I wrote BCX2Unicode with help from Garvan O'Keefe but last year Wayne Halsdorf wrote the UnicodeLexer and this is now my translator of choice.

How easy is compiling to unicode?
   Translating to Unicode is adding L or _T in front of quoted strings and changing from ANSI functions to unicode functions.
  And recompile using Unicode parameters in pocc command line call, see How I compile my BCX programs with PellesC
   Okay it is a little more complicated than that but not by much.

In BCX, just by adding a couple of lines to my base code I can compile the same code to run as Win32 ANSI, Win32 Unicode and with a couple of include files for Pocket PC and Smartphones.

BCX:

BCX by Kevin Diggins was designed to intepret Basic code to the 'C' equivalent.
It is easy to use and translates on average each line of Basic into 2-10 lines of 'C' code.

Considerations & Strategy for compiling to Win32 Unicode & WinCE:

1) I wanted a method to translate ANSI 'C' to Unicode either for Win32 or WinCE

2) While I had a choice between translating ANSI directly to Unicode only using the wchar.h translations, I decided that using the tchar.h file was more universal and more flexible.
    Using TCHAR.h would best suit my needs. This allows the compiler to decide if you want ANSI or Unicode, just define _UNICODE for a unicode compile.
    Instead of converting functionname  to wfunctionname it would be better to translate to _tfunctionname and let the compiler figure it out.
    But this is internal and you don't even need to read the translation.

3) As WinCE devices generally use a smaller screen size right now 3" Width * 4" Depth (1/4 VGA) I try to make my base code to a 1/4 VGA settings.
    I have code elsewhere to resize controls that can easily be added.

Recently I got PellesC to work for PPC and now use it almost exclusively.

UnicodeLexer:

Wayne Halsdorf used my BCX2Unicode idea and made UnicodeLexer.

UnicodeLexer Introduction:

UnicodeLexer  is basically a search & replace program with added features before the c compiler sees your code:

1) translates Windows API code to Windows Unicode API code
2) translates ANSI strings to Unicode i.e. "help" to _T("help"} or L"help" depending on on the switches used
3) used to either delete or translate code that absolutely will not work with Unicode / WinCE or other compilers.
4) Uses a comma delimited text file to store list of items to change
5) can generate a report of changed items,  see -d option
6) can accept several parameters (see BCX2Unicode  Readme.rtf)
7) Switch to turn off/on translation around ANSI essential code using
    //<---UNICODE AWARE translation off
    //>---UNICODE AWARE translation on
or
    !//$EMIT_ANSI switch
8) Can be used in Command Line mode or it will revert to GUI if no command line parameters are available


UnicodeLexer Command line Parameters:

1st parameter should be yourFilename.c(cpp) - this must be the whole path  and filename, can be .c  or .cpp

NONE: This will invoke a File Dialog box to input the filename and then Parameters input box.

Conversion file parameters:
none:  uses the file  TCHARXLATER.txt as the conversion file

-ppc : use the file TCHARXLATOR_PPC.txt as the conversion file
-g    : use the file  TCHARXLATER_USER.txt as the conversion file
         a different user filename can only be added in GUI mode.
-w  : use the file  TCHARXLATER_WIDE.txt as the conversion file
-u   : use the file  TCHARXLATER.txt as the conversion file (default)

Other parameters:
-t   : disable using '_T' in front of quoted strings defaults to adding L .
-l   : disable using 'L'  in front of quoted strings.
       NOTE: to turn off both adding '_T' and 'L' use -t -l

-d  : generate a LOG file, this file can be large as it will generate 3 lines per line of c code
  
     Not sure then start the UnicodeLexer.exe without Parameters and use the GUI interface

Compile from a C compiler:

Save your work and Run UnicodeLexerV3.exe from either the command line or in GUI mod from Windows explorer
In GUI mode add the filename you want to translate, and any other parameters.
Defaults are translate using the  tchar.h file, use _T to decorate strings.
Click on "Done".
Your file is now converted and use the appropiate compile string in your compiler to output your file.exe

NOTE: Your old file will be saved with the extension ".bak" and the translated file will have the ".c" extension
Look at the different pocc and polink commands I use below:

How I compile my BCX programs with PellesC:

If the file I want to convert is a BCX .bas file then I convert it to 'C' using command line  BC.exe filename.bas

ANSI:
Command line calls to the compiler:
pocc -W1 -Ot -Gd -Go -Ze -Zx -MT -Tx86-coff -D_WIN32_WINNT=0x0501  filename.c
polink -release -machine:ix86 -subsystem:windows filename.obj kernel32.lib advapi32.lib delayimp.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib

Win32 Unicode:
In my basic file I add:
   $ONEXIT "D:\BCX\Bin\BC_2_Unicode\unicodelexer.exe D:\BCX\WinCe\Calc\Calc.c"  'Change Paths to suit

Command line calls to the compiler:
pocc -W1 -Ot -Gd -Go -Ze -Zx -MT -Tx86-coff -D_WIN32_WINNT=0x0501 -DUNICODE -D_UNICODE filename.c
polink -release -machine:ix86 -subsystem:windows filename.obj kernel32.lib advapi32.lib delayimp.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib

WinCE:
In my basic file I add
   $ONEXIT "D:\BCX\Bin\BC_2_Unicode\unicodelexer.exe D:\BCX\WinCe\Calc\Calc.c -ppc"  'Change Paths to suit
   $INCLUDE "WinCesetup.bas"  'adds some include files and CEFunctions.bas
   $INCLUDE "PPConlyFunctions.bas"  'adds some PPC only includes and Menu Functions

Command line calls to the compiler:
pocc -W1 -Ot -Gd -Go -Ze -Zx -MT -Tarm-coff -D_WINCE -D_WIN32_WCE=0x400 -DARM -D_ARM_ -DUNICODE -D_UNICODE filename.c
polink -release -machine:arm  -subsystem:windowsce,4.0 filename.obj -stack:0x10000,0x1000 -version:1.1  aygshell.lib coredll.lib corelibc.lib commctrl.lib crtce.lib

News:

March 3rd 2010
 Added Version 3 with GUI mode and a couple of bug fixes

Feb 2010:
Started using Wayne Halsdorf's UnicodeLexer,  so far so good

Last update to BCX2Uncode Jan 26, 2008,
I started adding stuff for other compilers, now bcx2Unicode can work on variable lists in the functions:
 i.e. you need to change from functionA to functionB but variable lists don't match:

Dec. 22, 2008
I found that eVC and eVB were not on my new computer , after an install of these I'm still missing something, all errors are in the included ".h" files.
So I am converting all of these to compile on PellesC as time allows.
In PellesC:
ceListView.zip - compiled in PelesC - Updated 12/22/08

Links to my working programs:

These programs worked for me, some are getting a little old, but if there are bugs please let me know:

Please note these files are my own and are not in any way related to StarTrak Pigging, except being hosted here.
These are demos of programs I have put together to test BCX with WinCe Devices.

If you're one of the people the helped me by providing samples to the BCX, you may see I've used sample lines and sometimes whole functions, normally not without major modification.
Anyway thanks to all those that helped.

Needed programs:

BC.exe - Get the latest from http://groups.yahoo.com/group/BCX/
UnicodeLexerV3_1.zip - Source & exe of Unicode translator
Last version of  BCX2unicode.zip - Source & exe of my old Unicode translator

Some Notes on whats I've done:

See the BCX2Unicode Readme File in the BCX2Unicode zip file
WinCe dos&donts.rtf - My ramblings on what worked and what didn't and sometimes why:)
WinCE CommPort Notes.rtf - How I got Serial ports to work in WinCE
Use EZ-IDE w_WinCE.rtf - How far I got with using EZ-IDE in WinCE


Examples of some BCX WinCE programs:
Common:
      
CEsupportfiles.zip - Files I use in most programs


PELLESC:

ceListView.zip - compiled in PelesC - Updated 12/22/08
Same as ListVTest.zip but for PellesC
I have a section that can be commented out to use in XP
Uses Listview, Edit box(text), Static (label) and Buttons

 

Calc.zip  - Kevin Diggens calculator example - compiled in PellesC 5.08 - 2/2010
just comment in/out a couple of lines of code and it works for Win32 ansi, Win32Unicode or WinCe.

LanguageTest.zip - simple example to show how I add multiple languages to a BCX program. -3/2010
I made this unicode so I could use all the characters available.
This is for Win32Unicode or WinCe.

English View           Chinese View

UnicodeViewer.zip
Example of showing all unicode characters, has combobox for some language ranges (not all) - 3/2010
You can also use the rdit boxes to input other ranges of numbers.
This is for Win32Unicode or WinCe.


EVC++ 3.0
I think most of these files include the ".exe" file else you'll need to recompile.
At least you have the example code:)
I have since deleted and re-installed all my eVC and eVB stuff, missing some magic parameter to compile these again , hmm.


ceAccessIt.zip      -  Demo of using an Access database - compiled in eVC 3.0 - Updated 7/15/05

Access normal mode

SerialLogger.zip  - Demo of a Serial Port datalogger - compiled in eVC 3.0 -Updated 7/13/05

seriallogger

ListVTest.zip - Demo using a ListView control - compiled in eVC 3.0 -Updated 7/13/05



Bcxedit.Zip  - My First CE program using BCX (see credits) - compiled in eVC 3.0 -Updated 7/13/05

ceMail.zip - This can send and read mail but I haven't finished displaying the mail yet. - compiled in eVC 3.0 - Updated 7/13/05

Login Page    Send This


If you're one of the people the helped me  by providing samples to the BCX, you may see I've used sample lines and sometimes whole functions, normally not without major modification.
Anyway thanks to all those that helped.
Especially: Garvan O'Keefe, Doyle Whisenant (BCXEdit), Mike Henning and Kevin Diggins


Links to other BCX Sites:

Yahoo Group page - http://groups.yahoo.com/group/BCX/
Garvan O'Keefe's BCX Page -http://weekendcode.phatcode.net/
BCX SourceForge site - http://sourceforge.net/projects/bcx-basic/
BCX Gurus User Demos - http://www.bcxgurus.com/bcxusers/
BCXOLR - http://bcxolr.bcxgurus.com/default.htm
         
          BCX Blogs - http://www.basic-compiler.com/blog/