XE and Unicode

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Ingeloak
Posts: 3
Joined: Mon 27 Apr 2009 18:38

XE and Unicode

Post by Ingeloak » Mon 18 Oct 2010 21:30

I have been experiencing several Unicode issues with Delphi XE and DevArt products. I have created an empty Firebird database. In that database, I have created a table with one field, text_val, that is a blob field of sub type 1 (memo). It is defined with the UTF8 character set. UseUnicode is true and memos are enabled in my IBC components. All three of the issues below result in a "Cannot transliterate between character sets" error message:

Issue #1 - Modifying a WideMemo field:

Code: Select all

qryText.SQL.Text := 'select * from text where id = 1';
qryText.Open;
qryText.FieldByName('text_val').AsWideString := '來電者是劫持';
qryText.Post;
Issue #2 - Updating a WideMemo field with a parameter:

Code: Select all

qryText.SQL.Text := 'update text set text_val = :newval where id = 1';
qryText.ParamByName('newval').DataType := ftWideMemo;
qryText.ParamByName('newval').AsWideString :=  '來電者是劫持';
qryText.Execute;


Issue #3 - Updating a WideMemo field with a stream:

Code: Select all

var
  Buffer: string;
begin
  Buffer := '來電者是劫持'; 
  MemStream.Write(Pointer(Buffer)^, ByteLength(Buffer));
  MemStream.Position := 0;

  qryText.SQL.Text := 'select * from text where id = 1';
  qryText.Open;
  TBLOBField(qryText.FieldByName('text_val')).LoadFromStream(Stream);
  qryText.Post;
end;

AndreyZ

Post by AndreyZ » Tue 26 Oct 2010 08:26

Hello,

The point is that in RAD Studio XE the behaviour of the UnicodeToUtf8 function was changed. Therefore, we changed the behaviour of all DAC components to bypass this problem. This solution will be included in the next builds of all DAC components.

Ingeloak
Posts: 3
Joined: Mon 27 Apr 2009 18:38

Post by Ingeloak » Wed 27 Oct 2010 03:10

Thanks! Also, I'd like to post a potential fix for the WideMemo parameters. In InterBaseUniProvider.pas, add the following code to CreateParamObject:

Code: Select all

function TInterBaseUniProvider.CreateParamObject(Param: TDAParam): TSharedObject;
...
      {$IFDEF VER10P} // added
        if Param.DataType = ftWideMemo then // added
          TBlob(Result).IsUnicode := True; // added
      {$ENDIF} // added
...
end;

AndreyZ

Post by AndreyZ » Thu 28 Oct 2010 14:27

Thank you for your inquiry. Can you provide us a code example that might cause the error?

Ingeloak
Posts: 3
Joined: Mon 27 Apr 2009 18:38

Post by Ingeloak » Thu 28 Oct 2010 15:50

The error can be produced by using the code sample in Item #2 (from the first post in this thread) along with UniDAC's InterBase provider. Here it is again:

Code: Select all

qryText.SQL.Text := 'update text set text_val = :newval where id = 1'; 
qryText.ParamByName('newval').DataType := ftWideMemo; 
qryText.ParamByName('newval').AsWideString :=  '來電者是劫持'; 
qryText.Execute;

AndreyZ

Post by AndreyZ » Tue 02 Nov 2010 09:59

Thank you for the information. We fixed this problem.

Post Reply