How can I work with Chinese characters from the database?
I am facing the problem of capturing Chinese characters in a dataset.
In Delphi 2010, I tried two kinds of components:
- Delphi default
- Developer Express components
As a result, those components that are not bound to the data source work fine, but these components have such a reference to the data source. Chinese characters have been converted to question marks, except for TDBMemo. See image below.
A dataset is a client dataset with two fields:
- Name - string
- Description - Note
What should I do to make it work?
Link http://img97.imageshack.us/img97/9445/d2010unicodetestsimplif.gif
type
TForm1 = class(TForm)
ClientDataSet1: TClientDataSet;
ClientDataSet1Name: TStringField;
ClientDataSet1Description: TMemoField;
DataSource1: TDataSource;
ClientDataSet2: TClientDataSet;
ClientDataSet2Name: TStringField;
ClientDataSet2Description: TMemoField;
DataSource2: TDataSource;
source to share
In Delphi 2010, the property value is TStringField
and TMemoField's
has a type AnsiString
. It is for this reason that Chinese characters are not displayed in data controls.
Instead, you must declare the field type as ftWideString
or ftWideMemo
to be created TWideStringField
and TWideMemoField
accordingly.
source to share
1) I am using ClientDataset standalone without any data provider.
2) We expect the result to be the same for TEdit and TDBEdit. Isn't it D2010 native Unicode?
it's just a simple standalone ClientDataset:
TForm1 type = class (TForm)
ClientDataSet1: TClientDataSet;
ClientDataSet1Name: TStringField;
ClientDataSet1 Description: TMemoField;
DataSource1: TDataSource;
ClientDataSet2: TClientDataSet;
ClientDataSet2Name: TStringField;
ClientDataSet2 Description: TMemoField;
DataSource2: TDataSource;
source to share