Page 1 of 1

Unidac 5.0.1 and unicode

Posted: Wed 05 Jun 2013 15:19
by lao
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

Re: Unidac 5.0.1 and unicode

Posted: Thu 06 Jun 2013 11:18
by DemetrionQ
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.

Re: Unidac 5.0.1 and unicode

Posted: Thu 06 Jun 2013 12:19
by lao
hi, when i execute this code i have message like this:
â é
regards

Re: Unidac 5.0.1 and unicode

Posted: Thu 06 Jun 2013 12:24
by lao
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

Re: Unidac 5.0.1 and unicode

Posted: Fri 07 Jun 2013 10:39
by DemetrionQ
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;