2

It raises an exception: every time a Delphi XE-8 program executes this code:

procedure TForm_hora_edit_.SpdBtn_KOMISII_ZASEDANIA_Click(Sender: TObject);
begin
  Data_Module.IBQuery_KOMISII_ZASEDANIA_.Active := False;
  Data_Module.IBQuery_KOMISII_ZASEDANIA_.SQL.Text := 'SELECT * FROM KOMISII_ZASEDANIA ORDER BY ZASED_DT DESC';
  Data_Module.IBQuery_KOMISII_ZASEDANIA_.Active := True;  
end;

The exception is raised on this line:

Data_Module.IBQuery_KOMISII_ZASEDANIA_.Active := True;

Exception message:

No mapping for the Unicode character exits in the target multi-byte code page

I did create the table KOMISII_ZASEDANIA using a free software: SQL Manager Lite for IB/FB

The charset of the database is: UTF8; the table contains characters from the Cyrillic alphabet.

I need to avoid the above exception.

finalist
  • 49
  • 1
  • 8
  • Show me the properties of the TDataSet component you use to connect. Most probably you forgot to set connection charset – Arioch 'The Dec 14 '15 at 21:19
  • Find "lc_type" at http://www.ibase.ru/devinfo/ibx.htm and see forum at sql.ru – Arioch 'The Dec 14 '15 at 21:20
  • The component I use is: TIBQuery, it does not contain any property connection charset, ( and nothing similar to charset ). – finalist Dec 14 '15 at 21:24
  • try checking your database through https://ru.wikipedia.org/wiki/IBExpert // in after registering the database in that IDE - try three experiments: close the database, in registered properties set Connection Charset to { 1: NONE; 2: WIN1251; 3:UTF-8 }, open database, try to do your query if it would show the data or fail. Also I suggest you to check database and tables are in UTF-8, not in UNICODE_FSS – Arioch 'The Dec 14 '15 at 21:25
  • 1
    TIBQuery dows not float in the air - you connect it to the some DataBase component which should have correct connection parameters, including connection charset – Arioch 'The Dec 14 '15 at 21:26
  • did you create TField components for the query in design-time or are them autocreated in runtime? There are different TField-derived classes for AnsiString and UnicodeString/WideString. Typical gotcha is that even TWideString-type Field has non-Unicode .AsString property – Arioch 'The Dec 14 '15 at 21:29
  • FBConnection.Params.Values['lc_ctype'] := 'UTF8'; The TField components for the TIBQuery are autocreated at Runtime. – finalist Dec 14 '15 at 21:34
  • FBConnection.Params.Values['lc_ctype'] := 'WIN1251'; Does not raise any Exception activatng above TIBQuery. – finalist Dec 14 '15 at 21:45
  • check the correct charsets with `IBExpert `- there is combo-box with them there may be "UTF-8" identifier rather than "UTF8" or anything other pecularity – Arioch 'The Dec 14 '15 at 22:29
  • OTOH if you only use Cyrillics then 1251 connection is perfectly enough for you – Arioch 'The Dec 14 '15 at 22:30
  • Maybe IBX - or client DLL from Interbase - just works badly with Firebird. – Arioch 'The Dec 14 '15 at 22:36
  • This is a common beginner error, comes from not specifying the charset when connecting using IBX via firebird connection string. – Warren P Dec 15 '15 at 01:24
  • @WarrenP that was my first guess, but then he said above in comments that "FBConnection.Params.Values['lc_ctype'] := 'UTF8'" – Arioch 'The Dec 15 '15 at 16:25
  • My last opinion is that the free software: SQL Manager Lite for IB/FB contains a bug, which destroys the Charset of the fields during altering teir tables. I saw how after I added an UTF-8 field to a Primary key of the table, the content of that field was changed terrible to unreadable for me characters. So I stop to use: SQL Manager Lite for IB/FB and start to use: IBExpert - free for Cyrillic alphabet users ! I hope my Database is not corrupted because of using the: SQL Manager Lite for IB/FB. – finalist Dec 15 '15 at 21:25
  • using IBExpert make dump of the database metadata aka scheme aka structure into text script and see if all the tables/columns have correct chrasets/collations - and check sql.ru/forum/interbase – Arioch 'The Dec 16 '15 at 17:02
  • check via FB2 monitor tables, maybe `SQL Manager Lite` forgets to set charset to the collection it makes? maybe it connects with lc_type=NONE ? http://stackoverflow.com/questions/33939006 – Arioch 'The Dec 16 '15 at 17:07
  • It's also possible that the underlying database is not encoded in UTF8, even though he has specified that in the connection string. – Warren P Dec 17 '15 at 20:40

1 Answers1

1

The error shown is not an error of Firebird, it is likely an error of Delphi when it receives the bytes of the field and interprets them in UTF-8. Based on the comments and the description of the problem, it looks like the field is probably CHARACTER SET NONE, and the current content is likely in WIN1251 (or another single byte encoding), not UTF-8; having a character set NONE means Firebird cannot convert it to the target connection encoding and sends it as is, leaving it up to the client application to interpret it.

Make sure the field has a character set other than NONE or OCTETS and convert the current content as needed.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197