Page 1 of 1

Unicode problem with Lazarus version

Posted: Wed 26 Sep 2012 22:41
by snorkel
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?

Re: Unicode problem with Lazarus version

Posted: Fri 28 Sep 2012 08:37
by ZEuS
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;

Re: Unicode problem with Lazarus version

Posted: Mon 01 Oct 2012 16:16
by snorkel
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.

Re: Unicode problem with Lazarus version

Posted: Fri 05 Oct 2012 06:49
by ZEuS
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).

Re: Unicode problem with Lazarus version

Posted: Fri 19 Oct 2012 15:51
by snorkel
Thanks for the great support. Long live Lazarus :-)