How to force locale to Serbian Latin

Post Reply
dmajkic
Posts: 14
Joined: Fri Mar 02, 2012 11:08 am

How to force locale to Serbian Latin

Post 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.
User avatar
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

Post by Antonio Linares »

Please try this:

REQUEST HB_CODEPAGE_CS852

FUNCTION MAIN

HB_CDPSELECT( "CS852" )
...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
codemaker
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: How to force locale to Serbian Latin

Post 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
dmajkic
Posts: 14
Joined: Fri Mar 02, 2012 11:08 am

Re: How to force locale to Serbian Latin

Post 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
User avatar
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

Post 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 );
   ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
dmajkic
Posts: 14
Joined: Fri Mar 02, 2012 11:08 am

Re: How to force locale to Serbian Latin

Post by dmajkic »

Replace all CP_ACP with hb_vmCDP()
How can I rebuild FWH libs?
User avatar
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

Post 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,,
regards, saludos

Antonio Linares
www.fivetechsoft.com
dmajkic
Posts: 14
Joined: Fri Mar 02, 2012 11:08 am

Re: How to force locale to Serbian Latin

Post 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?
Post Reply