Memo1.Text := AnNote.FieldByName('ANBLOB').Value
I see chinese characters in Delphi 10.2, and in Latin characters in Delphi XE2.
The TField.Value
property returns a Variant
.
In 10.2, that Variant
likely contains just the raw data of the blob. When converting such a Variant
to a String
, all charset information is lost. You get "Chinese characters" (commonly known as "Mojibake") when raw ANSI bytes are mis-interpreted as UTF-16 bytes.
In XE2, that Variant
likely contains a pre-decoded string
instead of raw blob bytes.
You want the database driver to decode strings for you, using the charset from the database field's metadata. So you may be encountering a bug in the database driver in 10.2 that did not exist in XE2.
Memo1.Lines.Text := AnNote.FieldByName('ANBLOB').AsString
I see the character in Latin alphabet in Delphi 10.2, why is this?
TField.AsString
allows the database driver to decode the field data using the field's charset metadata as needed.
TEncoding
. – David HeffernanTEncoding.GetEncoding('ISO-8859-1')
orTEncoding.GetEncoding(28591)
, just be sure toFree()
the returnedTEncoding
object when you are done using it. – Remy Lebeau