Delphi XE2数据集字段类型TStringField不支持Unicode? [英] Delphi XE2 Dataset field type TStringField does not support Unicode?
问题描述
在Delphi XE2中,我一直在浏览TDataset类及其字符串字段,并注意到AsWideString返回一种UnicodeString类型。然而,它从函数TField.AsString:String中获取值,该值依次调用TFIeld.AsAnsiString:AnsiString。因此任何unicode字符都会丢失?此外,传递给TDataset.GetFieldData的缓冲区被声明为一个AnsiChar的数组。
我正确理解这一点?
不,您应该检查 TWideStringField 类,用于Unicode字段和 TStringField 类这是非Unicode字符串。 TField 只是一个基础类, TField.GetAsWideString 是一种具有后退实现的虚拟方法,该方法被Unicode感知的后代所覆盖。 >
I've been looking through the TDataset class and its string fields, in Delphi XE2 and noticed that AsWideString returns a type of UnicodeString. However it gets the value from the function TField.AsString: String which in turn calls TFIeld.AsAnsiString:AnsiString. Therefore any unicode characters would be lost? Also the buffer which is passed to TDataset.GetFieldData is declared as an array of AnsiChar.
Am I understanding this correctly?
No, you should be examining the TWideStringField class which is for Unicode fields and the TStringField class which is for non-Unicode strings. TField is just a base class and TField.GetAsWideString is a virtual method with a fall back implementation that is overridden by descendants that are Unicode aware.
这篇关于Delphi XE2数据集字段类型TStringField不支持Unicode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!