Unidac 5.0.1 and unicode

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

Unidac 5.0.1 and unicode

Post by lao » Wed 05 Jun 2013 15:19

Hi,
i used unidac 5.0.1 with postgresql and i have problem with french accent like â é.
my tuniconnection parameters are: charset UTF8 and useunicode set to true;
Delphi 2007.
no problem before with unidac latest vers 4.
regards

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Unidac 5.0.1 and unicode

Post by DemetrionQ » Thu 06 Jun 2013 11:18

Hello.

I can't reproduce the problem. I used the following code:

Code: Select all

{$APPTYPE CONSOLE}

uses
  Uni, PostgreSQLUniProvider, Dialogs;

var
  UConn: TUniConnection;
  UQ: TUniQuery;
begin
  UConn := TUniConnection.Create(Nil);
  try
    UConn.ProviderName := 'PostgreSQL';
    UConn.Server := 'db';
    UConn.Port := 5438;
    UConn.Username := 'postgres';
    UConn.Password := 'postgres';
    UConn.Database := 'deimos_db';
    UConn.SpecificOptions.Values['PostgreSQL.UseUnicode'] := 'True';
    UConn.Open;

    UQ := TUniQuery.Create(Nil);
    try
      UQ.Connection := UConn;
      UQ.SQL.Text := 'select ''â é'' as txt';
      UQ.Open;
      ShowMessage(UQ.Fields[0].AsString);
    finally
      UQ.Free;
    end;

  finally
    UConn.Free;
  end;
end.
Please check this code. If the problem doesn't repeat, edit it, so that the problem repeats.

lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

Re: Unidac 5.0.1 and unicode

Post by lao » Thu 06 Jun 2013 12:19

hi, when i execute this code i have message like this:
â é
regards

lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

Re: Unidac 5.0.1 and unicode

Post by lao » Thu 06 Jun 2013 12:24

i compil vers 5.0.1 with the make found in folder /source/delphi11 without change in file dac.inc.
have you try with delphi 2007?
regards

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Unidac 5.0.1 and unicode

Post by DemetrionQ » Fri 07 Jun 2013 10:39

Hello.

    Delphi 2009 and higher versions have full Unicode support. All previous versions (including Delphi 2007) do not support Unicode. It means that you cannot work with Unicode characters in the standard visual components. That's why, if you want to work with Unicode characters, you should use at least Delphi 2009.
    If you need to work with Unicode in Delphi 2007, you should encode and decode the Unicode text by yourself, for example:

Code: Select all

var
  wstring: WideString;
begin
  UniQuery1.SQL.Text := 'select txt from testTable';
  UniQuery1.Execute;
  wstring := Utf8Decode(UniQuery1.FieldByName('txt').AsString);
  MessageBoxW(0,PWideChar(wstring),'',0);
end;

Post Reply