Unicode problem with Lazarus version

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Unicode problem with Lazarus version

Post by snorkel » Wed 26 Sep 2012 22:41

Hi,
I have been porting my delphi app to lazarus and when I connect to a database
with a unicode name like this for instance:Россия

I get this error with useunicode enabled:
Image

The database is UTF8 encoded and it works on the Delphi version with the same code.

I think the problem is the FCL is not unicode while the LCL is and there must be some routine
that is using the FCL and the string is not being converted.

When I examine the tpgconnection database name in the debugger it shows the correct text
It just errors when I call the connect method.

I am using the latest source of PGdac as well.

Any ideas?

ZEuS
Devart Team
Posts: 240
Joined: Thu 05 Apr 2012 07:32

Re: Unicode problem with Lazarus version

Post by ZEuS » Fri 28 Sep 2012 08:37

Thank you for the information.
We have reproduced the error and investigation is in progress.
For now, to have an ability to connect to the Unicode-named database and use Unicode-named database objects you can use the following workaround:
1. Set the TPgConnection.Options.UseUnicode option to True;
2. Compile your project with the -Fcutf8 compiler custom option (in Lazarus 1.0, open the "Project -> Project Options" menu and set the option in the "Compiler Options -> Other -> Custom options" field).

When using this approach, you will have to set all Unicode-named values such as the database name and table names in run-time, for example:

Code: Select all

  PgConnection1.Database := 'Россия';
  PgConnection1.Connected := True;
  PgTable1.TableName := '"таблица"';
  PgTable1.Open;
Also, when using data-aware controls such as TDBGrid, you should manually set-up grid columns in run-time like this:

Code: Select all

  with DBGrid1.Columns.Add do begin
    FieldName := 'текст';
    Title.Caption := AnsiToUTF8('текст');
    Width := 100;
  end;

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Re: Unicode problem with Lazarus version

Post by snorkel » Mon 01 Oct 2012 16:16

Hi Thanks.

I will wait until you guys fix it as I am writing a query editor and can't really
hardcode the names like that. I am not done with my project where users would actually
need the unicode support yet anyway.

Thanks for the great support and the Lazarus version it's great.

ZEuS
Devart Team
Posts: 240
Joined: Thu 05 Apr 2012 07:32

Re: Unicode problem with Lazarus version

Post by ZEuS » Fri 05 Oct 2012 06:49

We have solved the problem.
The fix will be included in the nearest PgDAC build (we plan to release the next build in this month).

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Re: Unicode problem with Lazarus version

Post by snorkel » Fri 19 Oct 2012 15:51

Thanks for the great support. Long live Lazarus :-)

Post Reply