mySQL and UniCode

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
PatrikT
Posts: 3
Joined: Tue 13 Dec 2011 09:37
Location: Deutschland

mySQL and UniCode

Post by PatrikT » Tue 13 Dec 2011 09:57

Hi,

I'm Testing your unidac component, but I can't get it working with UTF8 in my DB. I have set Charset to UTF8, UseUnicode = True, but still not showing correct Values. :(

AndreyZ

Post by AndreyZ » Tue 13 Dec 2011 12:55

Hello,

You cannot show Unicode characters in the standard visual components in all Delphi versions earlier than Delphi 2009 because they do not support Unicode. Delphi 2009 and higher versions have full Unicode support. To solve the problem, you should use Delphi 2009 at least, or you can use some third-party visual components for displaying data with Unicode support.

PatrikT
Posts: 3
Joined: Tue 13 Dec 2011 09:37
Location: Deutschland

I'm using XE2

Post by PatrikT » Tue 13 Dec 2011 12:59

:( I'm using XE2 but it's still not shown...

PatrikT
Posts: 3
Joined: Tue 13 Dec 2011 09:37
Location: Deutschland

Post by PatrikT » Tue 13 Dec 2011 16:11

- Win7 64bit
- mySQL 5
- Delphi XE 2 Update 2

AndreyZ

Post by AndreyZ » Tue 13 Dec 2011 16:51

I have created the following table:

Code: Select all

CREATE TABLE testutf
(
  id INT(11) NOT NULL AUTO_INCREMENT,
  txt VARCHAR(40) DEFAULT NULL,
  PRIMARY KEY (id)
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET utf8
COLLATE utf8_general_ci;
, inserted the following data:

Code: Select all

INSERT INTO testutf (txt) VALUES ('ѮѶѪ')
, and used the following code:

Code: Select all

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  UniConnection1.ProviderName := 'MySQL';
  UniConnection1.Server := 'server';
  UniConnection1.Port := 3306;
  UniConnection1.Database := 'database';
  UniConnection1.Username := 'username';
  UniConnection1.Password := 'password';
  UniConnection1.LoginPrompt := False;
  UniConnection1.SpecificOptions.Values['UseUnicode'] := 'True';
  UniQuery1.Connection := UniConnection1;
  UniQuery1.SQL.Text := 'select * from testutf';
  UniDataSource1.DataSet := UniQuery1;
  DBGrid1.DataSource := UniDataSource1;
  UniQuery1.Open;
end;
Data from the testutf table was correctly shown in the TDBGrid component. Please check if this example works for you.

Post Reply