How to force locale to Serbian Latin

How to force locale to Serbian Latin

Postby dmajkic » Mon Aug 27, 2012 4: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.
dmajkic
 
Posts: 14
Joined: Fri Mar 02, 2012 11:08 am

Re: How to force locale to Serbian Latin

Postby Antonio Linares » Thu Sep 06, 2012 3:18 pm

Please try this:

REQUEST HB_CODEPAGE_CS852

FUNCTION MAIN

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to force locale to Serbian Latin

Postby codemaker » Thu Sep 06, 2012 9: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
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: How to force locale to Serbian Latin

Postby dmajkic » Fri Sep 07, 2012 9:00 pm

The problem is in oemansi.c:

Code: Select all  Expand view  RUN

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

Re: How to force locale to Serbian Latin

Postby Antonio Linares » 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: Select all  Expand view  RUN
// 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to force locale to Serbian Latin

Postby dmajkic » Sat Sep 08, 2012 10:25 am

Replace all CP_ACP with hb_vmCDP()


How can I rebuild FWH libs?
dmajkic
 
Posts: 14
Joined: Fri Mar 02, 2012 11:08 am

Re: How to force locale to Serbian Latin

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: How to force locale to Serbian Latin

Postby dmajkic » Sat Sep 08, 2012 7: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?
dmajkic
 
Posts: 14
Joined: Fri Mar 02, 2012 11:08 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 59 guests