I have been asked to connect a Lazarus application to a Firebird 3.0 database. The problem is, the database has been around for twenty years, and it was created without specifying any default charset.
Using FlameRobin, I can read/write strings containing accented characters without any problem. In the database registration info, I just leave NONE as the charset for the connection, and as long as we all work from the same environment (Windows / European language) everything gets stored and retrieved in the same charset, so we have no problem at all.
The problem comes with Lazarus, I can't find a way to properly configure the TIBConnection component to display accented strings correctly. I tried leaving its charset property empty, or setting it to NONE, ISO8859_1, WIN1252, or event UTF8... each time, the accented characters are replaced with question marks.
It seems to me that when you write to a database without specifying a charset, the database doesn't do any conversion and writes the characters as it receives them. Because of this, we are obliged to reread them in exactly the same conditions. That's what I can't reproduce with Lazarus.
What can I do to solve this problem?
Thanks :-)
Hello, I'm still stuck with my charset problem. I have tried several ways to convert the string, but none of these are working :
Edit1.Text := SQLQuery1.FieldByName('name').AsString;
Edit1.Text := Utf8ToAnsi(SQLQuery1.FieldByName('name').AsString);
Edit1.Text := AnsiToUtf8(SQLQuery1.FieldByName('name').AsString);
I'm trying to understand how the result string is encoded, so I display the hexadecimal value of each character. Here are two examples, where the question mark should be "è" (U+00E8) or "ë" (U+00EB). As you can see, this is exactly the values that I find in the hexadecimal codes :
Ad?le CROAIN
41 64 E8 6C 65 20 43 52 4F 41 49 4E 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
Jo?l DEKEYSER
4A 6F EB 6C 20 44 45 4B 45 59 53 45 52 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
I've been told that when the string is received from "AsString" it's too late to convert it, the string is already spoiled, and I should do the conversion somewhere else. Do you know what it means ? I have not been able to find myself...
Thank you all if you can help me :-)
Hello,
Did you have something like:
SQLQuery1.FieldByName('name').AsWideString
I’ve used FIB+ components for some time in Delphi. There was a difference using FieldByName(‘fieldname’).AsString or FieldByName(‘fieldname’).AsWideString.
See also FieldType ftWideString: https://wiki.freepascal.org/Database_field_type
Regards
Mathias
Von: firebird...@googlegroups.com [mailto:firebird...@googlegroups.com]
Im Auftrag von Marc Lebrun
Gesendet: Dienstag, 13. Februar 2024 09:46
An: firebird-support <firebird...@googlegroups.com>
Betreff: Re: [firebird-support] Lazarus + Firebird : question about charset
ACHTUNG: Diese E-Mail stammt von einem externen Absender. Bitte vermeiden Sie es, Anhänge oder externe Links zu öffnen.
--
You received this message because you are subscribed to the Google Groups "firebird-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
firebird-suppo...@googlegroups.com.
To view this discussion on the web, visit
https://groups.google.com/d/msgid/firebird-support/fb2ed8ff-db3f-49b6-b845-e5cb014cbf8an%40googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/e9247576-9be7-4b8e-aa16-691214d3e3dcn%40googlegroups.com.