XE and Unicode
Posted: 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:
Issue #2 - Updating a WideMemo field with a parameter:
Issue #3 - Updating a WideMemo field with a stream:
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;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;