How to put Chinese characters into dbf file

Moderator: Rathinagiri

Post Reply
Tiger
Posts: 70
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

How to put Chinese characters into dbf file

Post by Tiger »

Hi I have a stupid question if it is possible to import the excel file that contant the Chinese characters to dbf file. When I need to deal with the excel files I allways save it to "CSV" file 1st and then read the csv file and wirte it to dbf file, but when I open the dbf file by excel all the Chinese characters can't be read out correct. :cry: :cry: :cry:
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

How to put Chinese characters into dbf file

Post by Pablo César »

Tiger wrote:Hi I have a stupid question if it is possible to import the excel file that contant the Chinese characters to dbf file.
Hi. This is not a stupid question. IMO it is very important question.

DBFs from long time ago was created to store in OEM characters mode. But now in Harbour seems to be posible to store UNICODE mode into DBF. I have tested but now I do not remember which was the difficulties. But there is a field when creates DBF that you can define as "U" type for unicode but this fileds are extended and not compatible with Clipper/Dbase.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Tiger
Posts: 70
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: How to put Chinese characters into dbf file

Post by Tiger »

But there is a field when creates DBF that you can define as "U" type for unicode but this fileds are extended and not compatible with Clipper/Dbase.
Thanks Pablo, but I got an error message that said " Error DBCMD/1014 Argument error:DBCREATE" from the following code :

IF !File( "E_REPAIR.DBF" )
ADBF := {}
AAdd( ADBF, { "CTR_ID", "C", 10, 0 } )
AAdd( ADBF, { "LotCode", "C", 16, 0 } )
AAdd( ADBF, { "FailCode", "U", 36, 0 } )
AAdd( ADBF, { "E_F_code", "C", 20, 0 } )
AAdd( ADBF, { "Process", "C", 8, 0 } )
AAdd( ADBF, { "C_Date", "C", 16, 0 } )
AAdd( ADBF, { "C_BY", "C", 10, 0 } )
dbCreate( "E_REPAIR", ADBF )
ENDIF
USE E_REPAIR NEW
ZAP
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

How to put Chinese characters into dbf file

Post by Pablo César »

At this moment, I am not with my pc and can not tell you how I used and what used for.

You have not informed Harbour version and/or HMG version.

Probably you will need to use RDD CDX not NTX, because this other is for Clipper compatible.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How to put Chinese characters into dbf file

Post by Rathinagiri »

When I need to deal with the excel files I allways save it to "CSV" file 1st and then read the csv file and wirte it to dbf file
Hi,

Here the culprit may be Excel! Have you opened the CSV file in a normal text editor and it looks ok for you?

If not, you have to save as Unicode Text in Excel file. In this case, LibreOffice is far better.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Tiger
Posts: 70
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: How to put Chinese characters into dbf file

Post by Tiger »

Hi Rathi & Pablo,

Thanks for your help and hints. I found out what's wrong now. It's not caused by DBF,I think the problem is caused by the English OFFICE can't accept the Chinese characters. Now I will study if I can use the codepage or other methods to do that.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How to put Chinese characters into dbf file

Post by Rathinagiri »

That is what I am saying. You have to save it as Unicode Text file and not CSV.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Tiger
Posts: 70
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: How to put Chinese characters into dbf file

Post by Tiger »

Hi Rathi,

I think the CSV file is OK, because if I use the "import method" from EXCEL then the Chinese characters can be displayed correct. But if I just open it ( CSV or DBF) with EXCEL then it can't work. I used following codes to deal with EXCEL file when I need to get some data from it:
1. open excel file by OLE ==> oExcel := CreateObject( "Excel.Application" )
oExcel:WorkBooks:OPEN( "E_REPAIR.xls" )
2. And then save it to CSV format ==> oExcel:ACTIVEWORKBOOK:SAVEAS( E_REPAIR, xlCSV )
3. Open the CSV file and use substr function to restore some data to DBF file.
4. Save the DBF file to EXCEL, so other one can access it to do their report. oExcel:ACTIVEWORKBOOK:SAVEAS( "REPORT_DATA.XLS", xlExcel8 )

I know it might have other way to deal with EXCEL file, but as my program skill is not so good ... this way is what I can do now ...
Thanks for your hint, now I know the DBF file is OK and next step is how to save it to excel file.
Post Reply