Request of Codepage

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
ROBROS
Posts: 132
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF

Request of Codepage

Post by ROBROS » Thu Sep 13, 2018 9:35 am

Hi friends,

first of all: Thank you to Rathi and anyone involved in the work to make the forum availabe again. :D

My question:
I have to create a csv-file, I do this with set alternate to.
Now my problem:
In this file the german umlaute (ü,ä and so on) are not shown.
In "Harbour for Beginners" I read:

"This subsystem provides support for national code pages for your data. To link it to your application you must specify the library hbcpage.lib in a link - script and include in a chief prg file the proposal REQUEST with the names of the code pages, which you intend to use."

So, how do I specify the library in a link-script?
Thank you for your help.
Robert

edk
Posts: 341
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Request of Codepage

Post by edk » Thu Sep 13, 2018 10:13 am

Depending on what code page you have, you have to set CP in Harbour:

Code: Select all

#include "hmg.ch"

request HB_CODEPAGE_DE850
request HB_CODEPAGE_DEWIN
request HB_CODEPAGE_DEISO

set( _SET_CODEPAGE, "DE850" )		//set CP to DE850
set( _SET_CODEPAGE, "DEWIN" )		//set CP to DEWIN
set( _SET_CODEPAGE, "DEISO" )		//set CP to DEISO
Attachments
CP_test.zip
(873 Bytes) Downloaded 22 times

ROBROS
Posts: 132
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF

Re: Request of Codepage

Post by ROBROS » Thu Sep 13, 2018 6:26 pm

Hi edk,

thank you for your reply, but it didn't solve my problem.
If you got the time, see my attached zip. With these settings I can open the table "file.dbf" with excel or open office and the "umlaute" are displayed correctly.
But not in the the "kds.txt".

What am I doing wrong?

Robert
PS: how can I find out the codepage I am using?
Attachments
TEST.7z
(1.09 MiB) Downloaded 15 times

edk
Posts: 341
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Request of Codepage

Post by edk » Thu Sep 13, 2018 9:11 pm

Hi Robert.
Almost correct, but bbkunde.dbf is encoded in DE850 not DEWIN.

Code: Select all

#include "hmg.ch"


PROCEDURE Main

local cLine
request HB_CODEPAGE_DE850
request HB_CODEPAGE_DEWIN
//request HB_CODEPAGE_DEISO

//set( _SET_CODEPAGE, "DE850" )		
set( _SET_CODEPAGE, "DEWIN" )		
//set( _SET_CODEPAGE, "DEISO" )	



set alternate to ("KDS.txt")
set alternate on
//bbkunde.dbf is encoded in DE850, not DEWIN
use bbkunde alias kunde new codepage("DE850")

astruct:={{"NAME","C",30,0}}
dbcreate("FILE",astruct,"dbfntx")
use FILE alias FILE new exclusive


 DEFINE WINDOW Servisa ;
   AT 120,120 ;
   WIDTH 800 ;
   HEIGHT 800 ;
   ON INIT ahead() ;
   FONTNAME 'ARIAL' FONTSIZE 12;
   TITLE "DATA" ;
   MAIN 
 END WINDOW

 Servisa.center
 ACTIVATE WINDOW Servisa

 RETURN NIL

procedure ahead

//set console off
select kunde
do while !eof()
   cLine=name
   ? cLine
   select file
   dbappend()
   replace name with kunde->name
   select kunde
   skip
enddo
J
MsgInfo('END. File.dbf and KDS.txt are encoded in DEWIN')
close data

msgbox('Test CP DE850 of bbkunde.dbf')
use bbkunde alias kunde new codepage("DE850")
edit extended 
use

msgbox('Test CP DEWIN of bbkunde.dbf')
use bbkunde alias kunde new
edit extended 
use

msgbox('Test CP DE850 of file.dbf')
use file alias file new codepage("DE850")
edit extended 
use

msgbox('Test CP DEWIN of file.dbf')
use file alias file new
edit extended 
use

servisa.release

RETURN 
It seems to me that Excel defaults to opening dbf files in the code page of the console, i.e. the German version of Windows will be 850 and the Polish version will be 852
In openoffice, you can probably choose the code page in which to open the dbf file.

I quickly check coding using file preview in Total Commander.

Edward.

ROBROS
Posts: 132
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF

Re: Request of Codepage

Post by ROBROS » Fri Sep 14, 2018 6:50 am

Hi Edward,

your suggestion is working fine, thank you very much.
I highly appreciate to take benefit from this forum, without your help I surely would have given up.

Robert

PS: you are right: in openoffice 850 is suggested.

Post Reply