evaluate mydac about chinese

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
wuming
Posts: 2
Joined: Sun 23 Jun 2013 15:42

evaluate mydac about chinese

Post by wuming » Sun 23 Jun 2013 15:58

Hi!
I've download and install mydac for xe2 update4 hotfix1 trial version. I tried to display chinese using charset as big5 and unicode property as false. It can show normal chinese correct. But cannot show the chinese word which we built by ourself(all I used download from http://www.cns11643.gov.tw). for example: ''. The chinese word will be setup start at unicode (E000) in win7. Fetch data from mysql will display as '?' for the word from E000(unicode stored as 0xEE8080 in mysql database). How can I get it correct using mydac component? Thanks!

HERE is my develop enviroment settings:
OS: Win7 32-bit Traditional chinese
tool: C++ Builder XE2 update4 hotfix1
Install program:(Get from www.cns11643.gov.tw)
AIDB_soft_102_1_win32.exe
TW-Kai-98_1.TTF
TW-Sung-91_1.TTF

Daos
Posts: 3
Joined: Fri 28 Jun 2013 17:08

Re: evaluate mydac about chinese

Post by Daos » Fri 28 Jun 2013 19:58

Hello.

As far as I know, MyDAC does not change the text field data received from the server. If you set the TMyConnection.Options.Charset property, the server converts all sent text data to the specified charset. If the field has the same charset, the sent data does not change and you receive the original data. If you see the '?' symbol, it mean the following:
    1) The database did not save your specific character, the '?' character is stored instead.
    2) The type, that the IDE uses for storing text data, is not able to store your character.

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: evaluate mydac about chinese

Post by DemetrionQ » Tue 02 Jul 2013 11:14

Hello.

When you set TMyConnection.Options.Charset, MySQL server converts text fields to the specified charset. If on conversion to the specified charset the server doesn't find a correspondent character in this charset, it returns '?' instead.
The following code commands the server to convert an utf8 character with the code 0xEE8080 to big5 and convert the result to a binary. The retrieved result is shown on a client as a byte sequence:

Code: Select all

var
  bb: TBytes;
  bin_str: string;
  i: integer;
begin
  MyQuery1.SQL.Clear;
  MyQuery1.SQL.Add('SELECT cast(0xEE8080 AS CHAR CHARACTER SET utf8) INTO @str_utf8;');
  MyQuery1.SQL.Add('SELECT cast(@str_utf8 AS CHAR CHARACTER SET big5) INTO @str_big5;');
  MyQuery1.SQL.Add('SELECT cast(@str_big5 as binary);');
  MyQuery1.Open;

  bb := MyQuery1.Fields[0].AsBytes;
  bin_str := '';
  for i := 0 to length(bb) - 1 do
    bin_str := bin_str + IntToHex(bb[i],2) + ' ';
  ShowMessage(bin_str);
end;
Please run this code and check the result of the conversion of the utf8 character with the code 0xEE8080 by the server.

wuming
Posts: 2
Joined: Sun 23 Jun 2013 15:42

Re: evaluate mydac about chinese

Post by wuming » Wed 10 Jul 2013 07:20

Thanks, I'll try it!
I also think this is just charset setting problem. Just don't know how to set connection charset. Thanks for your reply~ :)

Post Reply