unicode char in Embedded example
unicode char in Embedded example
MyConnection.Options
charset : gbk
useunicode: true
test databse : gbk
field: char(10), gbk
mydac: 5.8.047
delphi : 2009
os: win xp
in the example, entry chinese char "", post, refresh, it will become to "?"
charset : gbk
useunicode: true
test databse : gbk
field: char(10), gbk
mydac: 5.8.047
delphi : 2009
os: win xp
in the example, entry chinese char "", post, refresh, it will become to "?"
thank you.Dimon wrote:I can not reproduce the problem.
Please send me a complete small sample to dmitryg*devart*com to demonstrate it, including a script to create and fill table.
I have send a program to you.
script to create table:
CREATE TABLE `state` (
`PIC_ID` int(11) unsigned NOT NULL auto_increment,
`TYPER1` char(5) NOT NULL default '',
`TYPER2` char(5) NOT NULL default '',
`TYPER3` char(5) NOT NULL default '',
PRIMARY KEY (`PIC_ID`)
) ENGINE=MyISAM AUTO_INCREMENT=100001 DEFAULT CHARSET=gbk ROW_FORMAT=FIXED;
// insert
procedure TfmMain.btn3Click(Sender: TObject);
var
qry: TMyQuery;
begin
qry := TMyQuery.Create(nil);
qry.Connection := MyConnection;
qry.SQL.Text :=
'insert into `state` (`typer1`) values ('''');' +
'insert into `state` (`typer1`) values (''錦錦'');' +
'insert into `state` (`typer1`) values (''錦'');';
qry.Execute;
qry.Free;
DBGrid.DataSource.DataSet.Refresh;
end;
// update
procedure TfmMain.btn1Click(Sender: TObject);
var
qry: TMyQuery;
begin
qry := TMyQuery.Create(nil);
qry.Connection := MyConnection;
qry.SQL.Text := 'update `state` set `typer1`=''''';
qry.Execute;
qry.Free;
DBGrid.DataSource.DataSet.Refresh;
end;
In my Embedded program, neighter insert nor update work well.
but the same program work well when I run with mysql server version.Dimon wrote:To solve the problem you should change font for all data control components on supporting this Unicode char. For example you can use the Tahoma font.
it does not work well with the embeded version!
**************************************
the insert button & update button cannot work!
**************************************
thank you.Dimon wrote:In the example you've sent to us the problem was that the chosen font can not display this symbol.
Please make sure that the Charset option is set to gbk, the UseUnicode option is set to False, and the font is Tahoma.
Also specify the code page used on your machine.
now the update button and the insert button did work,
but i cannot see the char "" still.
my code:
unit Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
DBCtrls, ExtCtrls, Grids, DBGrids, StdCtrls, ToolWin, ComCtrls, Buttons,
DBAccess, MyAccess, Db, MemDS, MyDacVcl, MyCall, MyClasses, MyScript,
MyEmbConnection, DAScript;
type
TfmMain = class(TForm)
DBGrid: TDBGrid;
DataSource: TDataSource;
ToolBar: TPanel;
StatusBar: TStatusBar;
MyTable: TMyTable;
MyScript: TMyScript;
MyConnection: TMyEmbConnection;
Memo1: TMemo;
Panel1: TPanel;
btClose: TSpeedButton;
btOpen: TSpeedButton;
DBNavigator: TDBNavigator;
btn1: TButton;
btn2: TButton;
btn3: TButton;
procedure btOpenClick(Sender: TObject);
procedure btCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure MyConnectionLog(const Text: String);
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure MyConnectionAfterConnect(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
private
{ Private declarations }
procedure ShowState;
public
{ Public declarations }
end;
var
fmMain: TfmMain;
implementation
{$R *.dfm}
procedure TfmMain.ShowState;
var
St: string;
procedure AddSt(S:string);
begin
if St '' then
St := St + ', ';
St := St + S;
end;
begin
St := '';
if MyTable.Active then
AddSt('Active')
else
AddSt('Inactive');
StatusBar.Panels[0].Text := St;
end;
procedure TfmMain.btn1Click(Sender: TObject);
var
qry: TMyQuery;
begin
qry := TMyQuery.Create(nil);
qry.Connection := MyConnection;
qry.SQL.Text := 'update `state` set `typer1`=''''';
qry.Execute;
qry.Free;
DBGrid.DataSource.DataSet.Refresh;
end;
procedure TfmMain.btOpenClick(Sender: TObject);
procedure CreateDatabaseStruct;
begin
MyConnection.Open;
MyScript.Execute;
MyConnection.Database := 'test';
MyTable.Open;
end;
begin
try
try
CreateDatabaseStruct;
MyTable.Open;
except
on E: EMyError do
begin
if E.ErrorCode = ER_NO_SUCH_TABLE then
begin
CreateDatabaseStruct;
MyTable.Open;
end
else raise;
end;
end;
finally
ShowState;
end;
end;
procedure TfmMain.btCloseClick(Sender: TObject);
begin
MyTable.Close;
ShowState;
end;
procedure TfmMain.FormCreate(Sender: TObject);
begin
MyConnection.Options.Charset := 'GBK';
DBGrid.Font.Name := 'Tahoma';
CreateDir('.\data');
CreateDir('.\data\Test');
end;
procedure TfmMain.FormShow(Sender: TObject);
begin
ShowState;
end;
procedure TfmMain.MyConnectionAfterConnect(Sender: TObject);
begin
// MyConnection.ExecSQL('set names gbk;', []);
end;
procedure TfmMain.MyConnectionLog(const Text: string);
begin
if Memo1 nil then
Memo1.Lines.Add(Text);
end;
procedure TfmMain.btn2Click(Sender: TObject);
begin
MyConnection.ExecSQL('truncate table `state`;', []);
DBGrid.DataSource.DataSet.Refresh;
end;
procedure TfmMain.btn3Click(Sender: TObject);
var
qry: TMyQuery;
begin
qry := TMyQuery.Create(nil);
qry.Connection := MyConnection;
qry.SQL.Text :=
'insert into `state` (`typer1`) values ('''');' +
'insert into `state` (`typer1`) values (''錦錦'');' +
'insert into `state` (`typer1`) values (''錦'');';
qry.Execute;
qry.Free;
DBGrid.DataSource.DataSet.Refresh;
end;
end.
It still could not display de char "", and ''錦錦''->''錦"
after press "update" button ( 'update `state` set `typer1`='''''; )
the value of the 3 records field typer1 became nothing.
a complete small sample to demonstrate the problem has been sent toDimon wrote:Please send me a complete small sample to dmitryg*devart*com to demonstrate the problem.
Also specify the code page used on your machine.
dmitryg*devart*com .
I can entry the character in my windows xp system and display well in nodpad .