[Lazarus] Codepage question
Mattias Gaertner
nc-gaertnma at netcologne.de
Fri Aug 15 13:32:22 CEST 2008
On Fri, 15 Aug 2008 13:04:44 +0200 (CEST)
Michael Van Canneyt <michael at freepascal.org> wrote:
> Hi,
>
> I have a DBF file which has data in some DOS codepage.
> I'm trying to get the contents displayed correctly in Linux.
>
> I am aware of the 'OnTranslate' event of the TDBF component.
> (obviously, all TStringFields have Transliterate set to True)
>
> I am also aware that there is some OEMToAnsi windows function
> which - in a delphi application - does the trick: the data
> is then displayed correctly if I do:
>
> function TMainForm.DBFFileTranslate(Dbf: TDbf; Src, Dest: PChar;
> ToOem: Boolean ): Integer;
> begin
> OemToAnsi(Src,dest);
> Result:=-1;
> end;
>
> Obviously, this works in Delphi because Windows uses the ANSI
> codepage.
>
> In lazarus (linux) this does not work. There is a space on the place
> of special characters (german umlauts, ringel-s and so on)
>
> I also know Lazarus uses utf8.
>
> So, How do I get my dos/ansi/whatever string displayed correctly in
> the grid?
Does that mean, you want to convert a string in a specific DOS
codepage to UTF-8 under Linux?
See lcl/lconvencoding.pas ConvertEncoding. With fpc2.3.1 it uses
libiconv to convert arbitrary encodings.
"iconv -l" gives you a list of all encoding names.
This is somewhat slow.
Or you can convince me that the DOS codepages should be added to the
unit. Then you will get fast converters.
Mattias
More information about the Lazarus
mailing list