Sign in Join

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

Mailing lists / lazarus / 2015-11

Encoding with SDF dataset

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Marc Santhoff

Hi,

when trying to us a TSdfDataset connected to a TDatasource and a TDBGrid, only some unicode symbols are shown (those little squares holding four tiny numbers) for string data.

The data files are encoded iso-8859 but I have found no switch for setting the encoding of TDataSource or TSdfDataset. When loading a TFileStream is used, but I did not find a property or method for changing the encoding on the fly in it, either.

How can I fix it?

TIA,
Marc

Marc Santhoff

Reply by email

Mark Morgan Lloyd
to Marc Santhoff
Marc Santhoff wrote 12 lines
Hi, when trying to us a TSdfDataset connected to a TDatasource and a TDBGrid, only some unicode symbols are shown (those little squares holding four tiny numbers) for string data. The data files are encoded iso-8859 but I have found no switch for setting the encoding of TDataSource or TSdfDataset. When loading a TFileStream is used, but I did not find a property or method for changing the encoding on the fly in it, either. How can I fix it?

In my limited experience depends critically on the version etc. of the OS you're running.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Marc Santhoff
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 16 lines
Marc Santhoff wrote: > Hi, > > when trying to us a TSdfDataset connected to a TDatasource and a > TDBGrid, only some unicode symbols are shown (those little squares > holding four tiny numbers) for string data. > > The data files are encoded iso-8859 but I have found no switch for > setting the encoding of TDataSource or TSdfDataset. When loading a > TFileStream is used, but I did not find a property or method for > changing the encoding on the fly in it, either. > > How can I fix it? In my limited experience depends critically on the version etc. of the OS you're running.

I don't understand. I'm using FreeBSD, but the program will run on Windows.

I'm seeking a hook for attaching sth. like "new := ANSI2Unicode(old)", or a switch for changing the expected encoding in one of those components involved. Man .csv importers do ask for the encoding, Openoffice does.

The alternative would be to parse the file and convert each string piece by piece, showing in a simple TStringGrid - I don't like that idea. ;)

Marc Santhoff

Reply by email

Marc Santhoff
to Marc Santhoff: when trying to us a TSdfDataset connected to a TDatasource and a TDBGrid, only some…
Marc Santhoff wrote 12 lines
Hi, when trying to us a TSdfDataset connected to a TDatasource and a TDBGrid, only some unicode symbols are shown (those little squares holding four tiny numbers) for string data. The data files are encoded iso-8859 but I have found no switch for setting the encoding of TDataSource or TSdfDataset. When loading a TFileStream is used, but I did not find a property or method for changing the encoding on the fly in it, either. How can I fix it?

Digging some TSream*-Classes in Unit Classes I think one way to go would be to make a TString-descendant of some type, maybe TCustomMemoryStream or TStringStream and add a method "ReadUTF8()" or similar. Or directly override the Read()-Method for returning converted Strings.

Still hoping for a more simple solution, any ideas or hints?

TIA,
Marc

Marc Santhoff

Reply by email

Marc Santhoff
to Marc Santhoff
Marc Santhoff wrote 15 lines
On Mi, 2015-11-04 at 19:01 +0100, Marc Santhoff wrote: > Hi, > > when trying to us a TSdfDataset connected to a TDatasource and a > TDBGrid, only some unicode symbols are shown (those little squares > holding four tiny numbers) for string data. > > The data files are encoded iso-8859 but I have found no switch for > setting the encoding of TDataSource or TSdfDataset. When loading a > TFileStream is used, but I did not find a property or method for > changing the encoding on the fly in it, either. > > How can I fix it? Digging some TSream*-Classes in Unit Classes I think one way to go would

t

be to make a TString-descendant of some type, maybe TCustomMemoryStream

TStream-

Show quoted text 8 lines
or TStringStream and add a method "ReadUTF8()" or similar. Or directly override the Read()-Method for returning converted Strings. Still hoping for a more simple solution, any ideas or hints? TIA, Marc
Marc Santhoff

Reply by email

Michael Van Canneyt
to Marc Santhoff
Marc Santhoff wrote 25 lines
On Do, 2015-11-05 at 14:25 +0100, Marc Santhoff wrote: > On Mi, 2015-11-04 at 19:01 +0100, Marc Santhoff wrote: >> Hi, >> >> when trying to us a TSdfDataset connected to a TDatasource and a >> TDBGrid, only some unicode symbols are shown (those little squares >> holding four tiny numbers) for string data. >> >> The data files are encoded iso-8859 but I have found no switch for >> setting the encoding of TDataSource or TSdfDataset. When loading a >> TFileStream is used, but I did not find a property or method for >> changing the encoding on the fly in it, either. >> >> How can I fix it? > > Digging some TSream*-Classes in Unit Classes I think one way to go would t > be to make a TString-descendant of some type, maybe TCustomMemoryStream TStream- > or TStringStream and add a method "ReadUTF8()" or similar. Or directly > override the Read()-Method for returning converted Strings. > > Still hoping for a more simple solution, any ideas or hints?

None. It is an old problem, see:

http://bugs.freepascal.org/view.php?id=16587

This can be easily solved when we start the Unicode RTL and classes.

Michael.

Reply by email

Marc Santhoff
to Michael Van Canneyt
Michael Van Canneyt wrote 25 lines
On Thu, 5 Nov 2015, Marc Santhoff wrote: > On Do, 2015-11-05 at 14:25 +0100, Marc Santhoff wrote: >> On Mi, 2015-11-04 at 19:01 +0100, Marc Santhoff wrote: >>> Hi, >>> >>> when trying to us a TSdfDataset connected to a TDatasource and a >>> TDBGrid, only some unicode symbols are shown (those little squares >>> holding four tiny numbers) for string data. >>> >>> The data files are encoded iso-8859 but I have found no switch for >>> setting the encoding of TDataSource or TSdfDataset. When loading a >>> TFileStream is used, but I did not find a property or method for >>> changing the encoding on the fly in it, either. >>> >>> How can I fix it? >> Still hoping for a more simple solution, any ideas or hints? None. It is an old problem, see: http://bugs.freepascal.org/view.php?id=16587 This can be easily solved when we start the Unicode RTL and classes.

OK, at least I'm not writing code already done.

Thanks,
Marc

Marc Santhoff

Reply by email

Marc Santhoff
to Michael Van Canneyt: None. It is an old problem, see: http://bugs.freepascal.org/view.php?id=16587 This can be…
Michael Van Canneyt wrote 17 lines
On Thu, 5 Nov 2015, Marc Santhoff wrote: > On Do, 2015-11-05 at 14:25 +0100, Marc Santhoff wrote: >> On Mi, 2015-11-04 at 19:01 +0100, Marc Santhoff wrote: >>> Hi, >>> >>> when trying to us a TSdfDataset connected to a TDatasource and a >>> TDBGrid, only some unicode symbols are shown (those little squares >>> holding four tiny numbers) for string data. >>> >>> The data files are encoded iso-8859 but I have found no switch for >>> setting the encoding of TDataSource or TSdfDataset. When loading a >>> TFileStream is used, but I did not find a property or method for >>> changing the encoding on the fly in it, either. >>> >>> How can I fix it?

Got to ask some more questions ...

Show quoted text 5 lines
None. It is an old problem, see: http://bugs.freepascal.org/view.php?id=16587 This can be easily solved when we start the Unicode RTL and classes.

How would that easy solution look like?

From digging the code and thinking about it it is clear that my

implementation has to be inside TSdfDataset or a descendant. It cannot be done using a special file stream because of the byte count change with UTF8.

How can the current system encoding be retrieved in a platfrom neutral way?

Would it be OK to only stick any string into Ansi2utf8() and hand over the result in this case? Here I know the files encoding and it is fixed to iso8859-1, no change ever.

But a general solution would have a property storing the files encoding and a list of known encodings, do fpc/lazarus have knowledge of encodings somewhere?

Marc Santhoff

Reply by email

Marc Santhoff
to Marc Santhoff
Marc Santhoff wrote 10 lines
On Do, 2015-11-05 at 15:57 +0100, Michael Van Canneyt wrote: > > On Thu, 5 Nov 2015, Marc Santhoff wrote: > > > On Do, 2015-11-05 at 14:25 +0100, Marc Santhoff wrote: > >> On Mi, 2015-11-04 at 19:01 +0100, Marc Santhoff wrote: > >>> How can I fix it? Got to ask some more questions ...

Forget about it. Too small budget, too much work. Stopped.

Marc

Marc Santhoff

Reply by email