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.
How to force locale to Serbian Latin
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to force locale to Serbian Latin
Please try this:
REQUEST HB_CODEPAGE_CS852
FUNCTION MAIN
HB_CDPSELECT( "CS852" )
...
REQUEST HB_CODEPAGE_CS852
FUNCTION MAIN
HB_CDPSELECT( "CS852" )
...
Re: How to force locale to Serbian Latin
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
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
The problem is in oemansi.c:
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
Code: Select all
// oemansi.c
LPWSTR AnsiToWide( LPSTR cAnsi )
{
WORD wLen;
LPWSTR cString;
...
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, cAnsi, -1, ( LPWSTR ) cString, wLen );
...
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to force locale to Serbian Latin
Dusan,
Please try the following change and let me know if it is fine for your needs:
Replace all CP_ACP with hb_vmCDP()
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
How can I rebuild FWH libs?Replace all CP_ACP with hb_vmCDP()
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: How to force locale to Serbian Latin
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,,
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
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.Use bcc32 this way to recompile them:
What is the proper way to rebuild fwh libs from source using MinGW compiler?