• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 136
  • Last Modified:

Cyrillic problem with DBASE III and Delphi XE2

How Can I Read Cyrillic text from Old DBF file. Get the code page on the text.Encoding to Unicode then
write into DBF file with the same code page as the original ?

Thanks in advance.
0
VIKTOR PEEV
Asked:
VIKTOR PEEV
  • 6
  • 3
  • 2
3 Solutions
 
Sinisa VukCommented:
I suspect that this wouldn't work. Old dbf use a single byte char String  - but very newest Delphi use two-bzte char Strings. I assume that you need make some transform functions for reading/writing (same dbf?)
0
 
VIKTOR PEEVAuthor Commented:
I understand that and Looking  Help for transformation ??
0
 
Sinisa VukCommented:
I need more details. Version of Delphi, which component you user to access dbf, do you want to read and write to same dbf,...?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
VIKTOR PEEVAuthor Commented:
I use Delphi XE2 and TDBF table .Read data from DBF . / Edit or Insert / In the same or similar DBF .
0
 
Sinisa VukCommented:
This is good. Xe2 can work in both ways using String (2xbyte chars) and AnsiString (1xbyte char). If  TDBFtable is compatible to this... you probably do not need to modify anything - if codepage of win is compatible with dbf. Try it and check results.
0
 
Geert GOracle dbaCommented:
DBASE III ?

i'd try to write it to a different table first, preferably with unicode support
set your os to  the cyrillic codepage 1251

you'll need a font too, which is capable of displaying the cyrillic characters

read the data
and then write it another database.

reading and writing it to the same dbase III might not work in every scenario

how the data is translated also depends on the settings of the database client you use
0
 
Geert GOracle dbaCommented:
from what i know
you typically read such data into an AnsiString with a certain codepage.

type
  TCyrString = AnsiString(1251);

yourstring: TCyrString;

yourstring := qry.FieldByName('FIELD').AsAnsiString;

Open in new window


and then copy that to a unicode string

str: string;
str := yourstring;

Open in new window

0
 
VIKTOR PEEVAuthor Commented:
Thanks for answer. I already try this approach but the problem is that
the DBF is from old DOS program that use some different code page.
I try with AnsiString(1251) , AnsiString(866) , AnsiString(855)  but not work.
Attach the DBF file.
I write a program on Delphi XE2 that work with a firebird and I need to / export or insert /
some cyrillic data to this old DBF with a same code page as a original
that can be read on old DOS program ?
test.ZIP
0
 
VIKTOR PEEVAuthor Commented:
Ok DBF use ASCII code
I convert my Text from Unicode to AnsiString(1251) then to Ascii
type
 CyrillicString = type AnsiString(1251);

procedure Conv_Ansi_ASCII(var S:CyrillicString) ; {ANSI -> ASCII}
var
 i:Integer;
begin
 for i:=1 to Length(s) do
   if Ord(S[i]) in [192..239] then S[i] := AnsiChar(Ord(S[i])-64) else
   if Ord(S[i]) in [240..255] then S[i] := AnsiChar(Ord(S[i])-16) else
   if Ord(S[i]) = 168 then S[i] := AnsiChar(Ord(240)) else
   if Ord(S[i]) = 184 then S[i] := AnsiChar(Ord(241));
end; 

Open in new window


Problem is when I Insert text to DATABASE true TDBF in Delhi XE 2 text goes wrong ??
if I save the text to text file and Insert it true TDBF in Delphi 7 everything is OK ?

??????

Thanks.
0
 
VIKTOR PEEVAuthor Commented:
Thanks to Geert Gruwez and Sinisa Vuk for a Help. I found solution without converting to ASCII. Simply use ADO with File DSN to connect DBF
File DSN is DBASE III and ASCII Collating Sequence ;
0
 
VIKTOR PEEVAuthor Commented:
Its work for me
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 6
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now