You are hereTDBF issues

TDBF issues


By ivankob - Posted on 15 July 2009

- troubles to assign [Full]FilePath to the current application directory, it tends to reset to the MSE* directory instead - thus problems with design-time bindings

- with cp866-2-ucs2 conversion applied (see the attachment), strings look OK in win-32 but partially broken in Linux (the DB file is cp866 encoded), it'snoa  afont issue since same char codes dipslay well and wrong ( question marks ).

- dates are 1980 year based (instead of 1899)

Also, since its' impoissible to assign conn params of encoding for TDBF, a wish - a transcoding procedure hook so that to transcode on-fly as long as data are being fetched.

PS:

The conversion unit of the example may extend such one(s) in "lib/common/i18n".

 

 

 

AttachmentSize
dbf_ru.rar7.07 KB

> - with cp866-2-ucs2 conversion applied (see the attachment), strings
> look OK in win-32 but partially broken in Linux (the DB file is cp866
> encoded), it'snoa afont issue since same char codes dipslay well
> and wrong ( question marks ).

"
if fielddefs[i].datatype = ftString
then fields[i].aswidestring:= c866toucs2(fields[i].aswidestring);
"
FPC TField.AsWideString converts from/to the system encoding by WideStringMananger. Reading AsWideString of cp866 encoded data does not work on utf8 Linux. Use
"
while not eof do begin
edit;
for i:=0 to i1-1 do begin
if fielddefs[i].datatype = ftString
then fields[i].aswidestring:= c866toucs2(fields[i].asstring);
end;
next;
end;
"
in order to convert the table encoding to the current locale. Must be called only once!

Or there is TStringField.Transliterate (I don't know why it is not published in FPC, tmsestringfield trunk 3091 has it published) and TDbfFile.UseCodePage or TDbf.OnTranslate.

> - troubles to assign [Full]FilePath to the current application directory,
> it tends to reset to the MSE* directory instead - thus problems with
> design-time bindings

Please more info.

> with cp866-2-ucs2 conversion applied (see the attachment), strings
> look OK in win-32 but ...

TDBF is not forked, please ask the TDBF maintainer.

>>Please more info.

whatever FIlePath is set by the IDE, FullFilePath will be reverted to the MSE* dir.

"
TDbf = class(TDataSet)
[...]
property FilePath: string read FRelativePath write SetFilePath;
property FilePathFull: string read FAbsolutePath write SetFilePath stored false;
[...]

procedure TDbf.SetFilePath(const Value: string);
begin
CheckInactive;

FRelativePath := Value;
if Length(FRelativePath) > 0 then
FRelativePath := IncludeTrailingPathDelimiter(FRelativePath);

if IsFullFilePath(Value) then
begin
FAbsolutePath := IncludeTrailingPathDelimiter(Value);
end else begin
FAbsolutePath := GetCompletePath(DbfBasePath(), FRelativePath); <<<<<<<<<----
end;
end;
"

Then how to set up TDBF so that 1) to use a database file in the app directory 2) to have this file's connection active in design time ?

 

Use absolute path in FilePath property or adjust application working directory or set DbfBasePath property.
Please remember that TDBF is no MSEgui component so you probably get better answers on FPC mailing list.