Page 1 of 1
How to force locale to Serbian Latin
Posted: Mon Aug 27, 2012 4:25 pm
by dmajkic
How to force locale in FWH application to always be Serbian Latin?
We need to display latin accented chars (like šđčžć) on user computer regardles of what
he have in "Code Page for Non-Unicode programs". This includes text in MainMenu, labels,
fields, grids.
Is there a way to use unicode in fwh app? Our dbf data is in cp852.
Thank you.
Re: How to force locale to Serbian Latin
Posted: Thu Sep 06, 2012 3:18 pm
by Antonio Linares
Please try this:
REQUEST HB_CODEPAGE_CS852
FUNCTION MAIN
HB_CDPSELECT( "CS852" )
...
Re: How to force locale to Serbian Latin
Posted: Thu Sep 06, 2012 9:20 pm
by codemaker
I tried everything and finally found the solution which is what I need.
1. While programming for Serbian, change the Language and Keyboard to Serbian
2. During dialogs designing the Serbian language selected. Then, when using fonts I use "Arial CE"
3. Compiling and linking process still in Serbian setup
The resulting program is all in Serbian
When the resulting program runs it would run normally with all Serbian šđčćž, the computer where this program will run, should use Serbian Display and Keyboard
PS:
Majkicu, ako imaš problema, javi se na
bpekic@gmail.com
Re: How to force locale to Serbian Latin
Posted: Fri Sep 07, 2012 9:00 pm
by dmajkic
The problem is in oemansi.c:
Code: Select all
// oemansi.c
LPWSTR AnsiToWide( LPSTR cAnsi )
{
WORD wLen;
LPWSTR cString;
...
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, cAnsi, -1, ( LPWSTR ) cString, wLen );
...
AnsiToWide() is called everywhere. It converts ansi string to unicode string using user code page for non Unicode programs.
And then that unicode string is used for drawing, creating windows, etc ...
BUT - we have a number of users who have En-US CP_ACP settings (for example required by corporate standard), but
use our software with CP852 or CP1250. We set that in REQUEST and cdp_Select() and etc... And that works with GTWVT.
Using MultiByteToWideChar( CP_ACP, ... ) when string is in fact cp852 (or cp1250 or anything different from CP_ACP) leads to
wrong Unicode converted code points for chars above #127, and the end result is garbled text on screen.
To fix this isue, I need Antonio to do conversion using Harbour API (respecting hb selected code page) instead of MultiByteToWideChar().
Regards
Dusan Majkic
Re: How to force locale to Serbian Latin
Posted: Sat Sep 08, 2012 10:00 am
by Antonio Linares
Dusan,
Please try the following change and let me know if it is fine for your needs:
Replace all CP_ACP with hb_vmCDP()
Code: Select all
// oemansi.c
LPWSTR AnsiToWide( LPSTR cAnsi )
{
WORD wLen;
LPWSTR cString;
...
MultiByteToWideChar( hb_vmCDP(), MB_PRECOMPOSED, cAnsi, -1, ( LPWSTR ) cString, wLen );
...
Re: How to force locale to Serbian Latin
Posted: Sat Sep 08, 2012 10:25 am
by dmajkic
Replace all CP_ACP with hb_vmCDP()
How can I rebuild FWH libs?
Re: How to force locale to Serbian Latin
Posted: Sat Sep 08, 2012 10:54 am
by Antonio Linares
You just need to change these files and recompile them:
FWH\source\function\c5cnew.c
FWH\source\function\fwbmp.c
FWH\source\winapi\ctrl2chr.c
FWH\source\winapi\ctrldraw.c
FWH\source\winapi\gettextw.c
FWH\source\winapi\oemansi.c
FWH\source\winapi\rects.c
FWH\source\winapi\text.c
Use bcc32 this way to recompile them:
c:\bcc582\bin\bcc32 -c -Ic:\harbour\include -Ic:\fwh\include module.c
c:\bcc582\bin\tlib.exe fivehc.lib -+ module.obj,,
Re: How to force locale to Serbian Latin
Posted: Sat Sep 08, 2012 7:07 pm
by dmajkic
Use bcc32 this way to recompile them:
Since I am about to make changes to the lib, I would like to add it to Git source control, and make whole app and libs build automatic.
What is the proper way to rebuild fwh libs from source using MinGW compiler?