[fpc-pascal] TSQLQuery.ApplyUpdates problem with UTF-8

Dennis Poon dennis at avidsoft.com.hk
Fri Mar 14 12:22:43 CET 2014


Is TSQLQuery.AppleUpdate works with UTF8 string field content?

I fetched a web page and extracted part of its content and appended it 
into TSQLQuery record's string field.

The web page content is Chinese in UTF-8  encoding.
I 'writeln' the content before appending it and it appeared normal in 
the console.

The database is MYSQL 5.5 on ubuntu Intel 64-bit.

However, when I use MYSQL command to

    select * from MYTABLE;

the content appeared as garbage.

I already specified the CHARSET=utf8  in the Create Table SQL.

If I directly issue INSERT statement via MYSQL command prompt, it worked 
without garbage.

CREATE TABLE IF NOT EXISTS  `PROVIDERS` (
  `Key` int(10) unsigned NOT NULL auto_increment,
`CName` varchar(50) default '',
`Name` varchar(50) default '',

`Tel` varchar(50) default '',
`Address` varchar(200) default '',
`WebSite` varchar(80) default '',
`Email` varchar(50) default '',

`ListKey` int(10) signed default 0,
`PageNo` int(10) signed default 0,

PRIMARY KEY (`Key`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


I suspect the problem is in TSQLQuery's  generating the Insert statement 
which did not take the string as UTF-8.

How do I confirm this suspicion? and how to solve it?

Thanks in advance.

Dennis




More information about the fpc-pascal mailing list