FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to force locale to Serbian Latin
Posts: 14
Joined: Fri Mar 02, 2012 11:08 AM
How to force locale to Serbian Latin
Posted: Mon Aug 27, 2012 04:25 PM

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.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to force locale to Serbian Latin
Posted: Thu Sep 06, 2012 03:18 PM

Please try this:

REQUEST HB_CODEPAGE_CS852

FUNCTION MAIN

HB_CDPSELECT( "CS852" )
...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 208
Joined: Wed Dec 03, 2008 04:48 PM
Re: How to force locale to Serbian Latin
Posted: Thu Sep 06, 2012 09:20 PM

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

Posts: 14
Joined: Fri Mar 02, 2012 11:08 AM
Re: How to force locale to Serbian Latin
Posted: Fri Sep 07, 2012 09:00 PM
The problem is in oemansi.c:

Code (fw): Select all Collapse
// 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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to force locale to Serbian Latin
Posted: Sat Sep 08, 2012 10:00 AM
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 (fw): Select all Collapse
// 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
Posts: 14
Joined: Fri Mar 02, 2012 11:08 AM
Re: How to force locale to Serbian Latin
Posted: Sat Sep 08, 2012 10:25 AM
Replace all CP_ACP with hb_vmCDP()


How can I rebuild FWH libs?
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to force locale to Serbian Latin
Posted: Sat Sep 08, 2012 10:54 AM

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
Posts: 14
Joined: Fri Mar 02, 2012 11:08 AM
Re: How to force locale to Serbian Latin
Posted: Sat Sep 08, 2012 07:07 PM
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?

Continue the discussion