Home
Unicode Programming
WinCe Programming
BMFD Programs
Miscellaneous
codes
Semi - OOP codes
Languages Code
BCXOLR
Android
programming
Links to other great BCX
sites
|
Introduction:
Back in 2004 I needed a way to compile for WinCe,
after alot of searching I found BCX and thought I
could easily add a Unicode version suitable to
compile with eVC++. I got alot of help from Garvin
O'Keefe and I soon had a version of BCX2Unicode
working.
In 2010 Wayne Halsdorf took my idea and created
UnicodeLexer. This is now my translator of choice.
What is
Unicode?
ASCII characters are 8 bits, 0-255 characters.
Unicode characters are 16 bits or 65235
characters.
PellesC and most compilers have an option to allow
you to specify either ANSI, Unicode or leave it to
the compiler to decide depending on the compile
parameters.
By default BCX compiles strings as ASCII.
If you want to use Wide strings then use Wchar.h
Wide Strings must have a specifer 'L' .
i.e. : a$ = L("some text")
OR
if you want the compiler to decide depending on the
compile parameters then use Tchar,h
Strings must have a specifer '_T' . i.e.
: a$ = _T("some text")
What is the
difference for functions?
Windows has a lot of built in functions and API's
that deal with strings, the default is ASCII.
Normally the difference between these ASCII
functions and Unicode counterparts is a Wide
(Unicode) version of the function has a "w" or "t"
somewhere in the name.
i.e. fprintf or fwprintf or ftprintf
What is
UnicodeLexer?
UnicodeLexer.exe is a program that reads the ASCII
''C' or "C++" code emitted by BCX and translates it
to Unicode before it goes to the compiler.
BCX has an extremely useful function called $ONEXIT
that can call the UnicodeLexer before it exits and
before the 'C' compiler starts.
It will also translate any C or C++ code keywords
from ASCII to the Unicode version.
Download
UnicodeLexer 3.4
My Strategy
for compiling to Win32 Unicode & WinCE:
There are 2 ways of doing this:
1) Writing your whole program using the correct code
for unicode.
As seen above adding
L() to every string in your program could be a lot
of work, not to mention checking that every 'C'
function has the unicode version.
Also some BCX internal functions need to be
changed for this to work.
2) Writing your program in ASCII and translating
using UnicodeLexer.
All the programmer
needs to do is add the $ONEXIT call to
UnicodeLexer with the 'C' file name to translate.
There are some mixed ASCII / Unicode functions
that the user must beware of but these are small
in comparison.
There is also a 'c' translation file called tchar.h
that lets the compiler decide to use the ASCII or
Unicode translation. I found this the easiest to
use. This is added in the UnicodeLexer.by default.
The programmer must add the correct parameters for
this to work.
Wayne Halsdorf used
my BCX2Unicode idea and made UnicodeLexer.
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
1st parameter should
be yourFilename.c(cpp) - this must be the whole
path and filename, can be .c or .cpp
No Command line will invoke a File Dialog box to
input the filename and then Parameters input box.
Once you have your file name then these are some
switches to configure the output
Conversion file parameters:
none: uses the file TCHARXLATER.txt as
the conversion file (-u default)
-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 and check the results.
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
|