Recent

Author Topic: FIREBIRD db CharSet=WIN1251, TZQuery does not display WIN1251  (Read 12573 times)

finalist

  • Jr. Member
  • **
  • Posts: 99
I did create a FIREBIRD database CharSet=WIN1251, and a table MATERIALS.
I did write a MATERIAL with Cyrillic characters ( WIN1251 ) into table.
Then using Zeos Access components by LAZARUS: TZConnection, TZQuery, TDataSourse and TDBGrid it displaed the name of material not correct, but with ????? characters only ....
Is there any way to setup TZConnection to work correctly with Charset=WIN1251 ( Cyrillic alphabet ) ?
Thank you !

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: FIREBIRD db CharSet=WIN1251, TZQuery does not display WIN1251
« Reply #1 on: July 11, 2011, 09:08:50 pm »
I would recommend using UTF8 as character set in Firebird.  I never had any problems then, whether Cyrillic or Greek or even Chinese.
I'm using FB 2.5 and Zeos 7.0.0 (but SQLDB works equally well).  On Windows that is.
« Last Edit: July 11, 2011, 09:16:24 pm by Arbee »
1.0/2.6.0  XP SP3 & OS X 10.6.8

finalist

  • Jr. Member
  • **
  • Posts: 99
Re: FIREBIRD db CharSet=WIN1251, TZQuery does not display WIN1251
« Reply #2 on: July 11, 2011, 09:27:02 pm »
I am working under Windows 7.
I am using FB 2.1.4 and Zeos 6.6.6-stable.
It is fine for me that Zeos does not need installed-FB, it is enough some dynamic libraries (*.dll) into the folder that contains the application and the FB-database.
I changed the db CharSet to UTF8, but the problem persists ....
« Last Edit: July 11, 2011, 09:28:40 pm by finalist »

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: FIREBIRD db CharSet=WIN1251, TZQuery does not display WIN1251
« Reply #3 on: July 11, 2011, 09:39:04 pm »
Just try putting the line "codepage = UTF8" in ZConnection.Properties property. Actually, your FB server knows that the db is encoded in Win1251, but you need to tell to server what the client encoding is (and it is always UTF8 in LCL), so that the server converts encoding properly when communicating with your application.

finalist

  • Jr. Member
  • **
  • Posts: 99
Re: FIREBIRD db CharSet=WIN1251, TZQuery does not display WIN1251
« Reply #4 on: July 11, 2011, 09:56:36 pm »
Here is the Method OnCreate:
Code: [Select]
procedure TForm_PTO.FormCreate(Sender: TObject);
begin
  DBFolder := ExtractFilePath(Application.ExeName);
  DBName := DBFolder + 'PTOZEOSFB214.FDB';
  ZConnection.Connected := False;
  ZConnection.Properties.Codepage := 'UTF8'; // => the compiler cant compile this row
  ZConnection.User := 'SYSDBA';
  ZConnection.Password := 'masterkey';
  ZConnection.Protocol := 'firebirdd-2.1';
  ZConnection.HostName := '';
  ZConnection.Database := DBName;
  ZConnection.Connect;
  ZQuery.Active := True;
end;

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: FIREBIRD db CharSet=WIN1251, TZQuery does not display WIN1251
« Reply #5 on: July 11, 2011, 10:05:51 pm »
Code: [Select]
...
  ZConnection.Properties.Codepage := 'UTF8'; // => the compiler cant compile this row
...

No, see:
Code: [Select]
...
ZConnection.Properties.Add('codepage=UTF8');
...
:)

Or, better, in designtime use object inspector and edit ZConnection.Properties property and add the line: codepage=UTF8
« Last Edit: July 11, 2011, 10:07:22 pm by Zoran »

finalist

  • Jr. Member
  • **
  • Posts: 99
Re: FIREBIRD db CharSet=WIN1251, TZQuery does not display WIN1251
« Reply #6 on: July 11, 2011, 10:21:50 pm »
Thank you Zoran !
Now it works perfect when I work with my Lazarus Application.
Thank you again !!!!
« Last Edit: July 11, 2011, 10:32:25 pm by finalist »

Zoran

  • Hero Member
  • *****
  • Posts: 1831
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: FIREBIRD db CharSet=WIN1251, TZQuery does not display WIN1251
« Reply #7 on: July 11, 2011, 10:46:34 pm »
Thank you Zoran !
Now it works perfect when I work with my Lazarus Application.

You are welcome. :)

Now it is impossible to insert data using IBExpert, but this is not so bad ....
Thank you again !!!!

Oh, no, no, let's not just leave it so, why would it be impossible to insert data using IBExpert?
First, your db can still be in CP1251, as I said, the server knows what the db encoding is, we just needed to tell the server what the client encoding is.
However, if you already converted the db data to utf8, even better. Then in IBExpert you should do this: when the database is disconected, right-click on its node on the left, okey? Then open "Database registration info..." In the dialog, find "Charset" combo box and set it to utf8 (see attached image).


finalist

  • Jr. Member
  • **
  • Posts: 99
Re: FIREBIRD db CharSet=WIN1251, TZQuery does not display WIN1251
« Reply #8 on: July 11, 2011, 11:12:21 pm »
Don't worry, it was a temporary problem with IBExpert.
I did delete the one material I was postet into the table MATERIALS with IBExpert.
Then I did try 3-4 times to post a new material, but it was unsuccesful by IBExpert.
Then I did try to post a new material with LAZARUS Application SUCCESSFUL.
Next time I did open database with IBExpert Idid add materials SUCCESSFUL.
So there is no more problem with IBExpert.
Thanks !

 

TinyPortal © 2005-2018