Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-08

Codepage question

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

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?

Michael.

Reply by email

Mattias Gaertner
to Michael Van Canneyt
Show quoted text 29 lines
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

Reply by email

Michael Van Canneyt
to Mattias Gaertner
Mattias Gaertner wrote 35 lines
On Fri, 15 Aug 2008 13:04:44 +0200 (CEST) Michael Van Canneyt 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?

Yes.

Show quoted text 6 lines
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.

I beat you to that, the rtl has this since a very long time (using external files, see rtl/ucmaps) and I just finished a small program that creates include files with pascal constructs for the character maps. So actually you don't need iconv any more. All needed routines exist as pure pascal code.

I just started a thread on FPC Core to see how we can best structure an interface for this in the FPC packages.

Meanwhile, I'll have a .

Reply by email

Arí Ricardo Ody
to Michael Van Canneyt

Finally Lazarus seems to be operational under windows vista. But I must to do a manual operation after install it. I must change the configuration files directories.

I'd like to suggest to the developer team that when installing under Vista use "c:\User\<user>\AppData|local\lazarus" as default directory for configuration files. It's, more or less, the translation of "c:\documents and settings\<user>\application data\local settings\lazarus"(thanks to mr. Felipe Carvalho from Sao Paulo who gives me this information) from XP to new(and complex) Vista directories approach.

The command to call Lazarus in the shortcut was:

C:\lazarus\lazarus.exe --primary-config-path=c:\Users\ADM\AppData\Local\lazarus

Cheers

Ricardo

Reply by email