Recent

Author Topic: Cyrillic chars as ??? in FB Database with WIN1251  (Read 16651 times)

62mkv

  • New member
  • *
  • Posts: 9
Cyrillic chars as ??? in FB Database with WIN1251
« on: March 28, 2010, 02:40:19 pm »
I have a FB 1.0.3 Database, with a following DDL:

SET SQL DIALECT 3;

SET NAMES WIN1251;

CREATE DATABASE 'YMKM:C:\Develop\ezTask\Db\ezt1.fdb'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 16384
DEFAULT CHARACTER SET WIN1251;

I'm a newbie to Lazarus, trying to switch from Delphi 7

and the most simple thing brought me "on my knees" - I cannot achieve a normal work with this DB on an LCL form.

All the DBxxx components display only the  ???? (question marks) instead of russian text in a DB, while Latin text in the very same filed are displayed OK

the only Lazarus relevant setting in Lazrus, that I could find, is a property Charset of TIBConnection. Of course I set it to "WIN1251", as I would normally do in Delphi, but.. the result is on a screenshot.
Lazarus 0.9.29 snapshot 2010-04-24 FPC 2.4.0 SVN 24868 Win32
WinXP Pro SP3

Paul Ishenin

  • Sr. Member
  • ****
  • Posts: 274
Re: Cyrillic chars as ??? in FB Database with WIN1251
« Reply #1 on: March 28, 2010, 03:54:53 pm »
Lazarus uses UTF8 strings and you are getting strings in win1251 encoding. As result they are shown as question marks. Try to setup your database connection or convert your database to UTF8. At work I'm using firebird 2.1 database with UTF8 database. I have no problems to represent that data in lazarus database components.

62mkv

  • New member
  • *
  • Posts: 9
Re: Cyrillic chars as ??? in FB Database with WIN1251
« Reply #2 on: March 28, 2010, 04:04:37 pm »
>Try to setup your database connection
this is what I am asking for !!! HOW to do that ?

>or convert your database to UTF8.
it's currently impossible - there're several already widely used Delphi applications worknig with this database. too much for just for "his majesty Lazarus" compatibility
Lazarus 0.9.29 snapshot 2010-04-24 FPC 2.4.0 SVN 24868 Win32
WinXP Pro SP3

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Cyrillic chars as ??? in FB Database with WIN1251
« Reply #3 on: March 28, 2010, 05:15:12 pm »
>Try to setup your database connection
this is what I am asking for !!! HOW to do that ?

If you use ZEOS components, add this line to ZConnection's "properties" property:
Code: [Select]
codepage=UTF8

If you are using SqlDB (IBConnection), then probably you can do same by adding this line to params property. Try.

This should tell the server what your client encoding is (and it is UTF8). Then, the server should convert text before sending it to your application.
« Last Edit: March 28, 2010, 05:18:31 pm by Zoran »

62mkv

  • New member
  • *
  • Posts: 9
Re: Cyrillic chars as ??? in FB Database with WIN1251
« Reply #4 on: March 29, 2010, 05:03:23 pm »
Probably but NOT

this changes nothing in this behaviour.

is it possible (if yes then how) to tell about this problem to SqlDb developers ?
Lazarus 0.9.29 snapshot 2010-04-24 FPC 2.4.0 SVN 24868 Win32
WinXP Pro SP3

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Cyrillic chars as ??? in FB Database with WIN1251
« Reply #5 on: March 29, 2010, 05:48:31 pm »
Probably but NOT

Probably it was not supported in old Firebird version 1, which you use.

is it possible (if yes then how) to tell about this problem to SqlDb developers ?

It is probably possible, I don't know how.
If you try ZEOS, you can ask for support on their forum.
It might be worth trying, but I am afraid that you'll get the answer to switch to Firebird 2.1.3.

62mkv

  • New member
  • *
  • Posts: 9
Re: Cyrillic chars as ??? in FB Database with WIN1251
« Reply #6 on: April 01, 2010, 02:27:24 pm »
thanx, but I think it's uncorrect advice - "Switch to Firebird 2.1.3"

it's just like you would ask for advice, on where to get higher wheels for you Toyota Vitz, in order to ride better on bad roads in Russia (they're truly horrible here) and they would advice you to move to Germany with theirs autobahns and forget about this old unsupported Russia :)

I want to say that I would long ago switch to FB 2.1.3, to MS SQL or Oracle or whatever, if I could to !!
Lazarus 0.9.29 snapshot 2010-04-24 FPC 2.4.0 SVN 24868 Win32
WinXP Pro SP3

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Cyrillic chars as ??? in FB Database with WIN1251
« Reply #7 on: April 01, 2010, 04:39:18 pm »
thanx, but I think it's uncorrect advice - "Switch to Firebird 2.1.3"

it's just like you would ask for advice, on where to get higher wheels for you Toyota Vitz, in order to ride better on bad roads in Russia (they're truly horrible here) and they would advice you to move to Germany with theirs autobahns and forget about this old unsupported Russia :)

I want to say that I would long ago switch to FB 2.1.3, to MS SQL or Oracle or whatever, if I could to !!

Sorry, I apologize. :-[

I'm just afraid that old Firebird server can't do converting to UTF8 charset for you, but I don't know.

Actually, you might be able to get responce from SQLdb developers if you put a bug report on bugtracker.

Try also to ask ZEOS team on their forum about your problem.

I'm afraid that you might get answer that they will not put hard work now to support old database version, but you should try.

If that is the case, try using fiels' OnGetText and OnSetText, that is a workaround (as described here: http://www.lazarus.freepascal.org/index.php/topic,5963.msg43634.html#msg43634).

cd

  • Jr. Member
  • **
  • Posts: 54
Re: Cyrillic chars as ??? in FB Database with WIN1251
« Reply #8 on: April 02, 2010, 06:47:30 pm »
if it is possible in your case you could manually convert strings to utf8 using
Code: [Select]
function AnsiToUtf8(const s : ansistring): UTF8String;i do such things for old sqlite-based win1251 database.

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Cyrillic chars as ??? in FB Database with WIN1251
« Reply #9 on: April 02, 2010, 08:37:23 pm »
if it is possible in your case you could manually convert strings to utf8 using
Code: [Select]
function AnsiToUtf8(const s : ansistring): UTF8String;i do such things for old sqlite-based win1251 database.

If you know which encoding it is, you should use functions from LConvEncoding unit instead of AnsiToUTF8, in this case it would be CP1251ToUTF8 function.

Like in example from the topic I linked to in my previous post:
Code: [Select]
uses
  ... , LConvEncoding;

.....

procedure TForm2.ZQuery1Field2GetText(Sender: TField; var aText: string;
  DisplayText: Boolean);
begin
   aText := CP1251ToUTF8(Sender.AsString);
end;

 

TinyPortal © 2005-2018