MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:devy Date:January 22 2006 11:32am
Subject:mysql and utf8
View as plain text  
Hi list,

I'm having some problems while trying to save into a TEXT field some data
containing text and special characters from a C program!
I thought to convert the special characters with UTF8 but I don't know how
to write the SQL-query to insert data in the following table:

CREATE TABLE `books`
(
  `id` int(11) NOT NULL auto_increment,
  `txt` text character set latin1 NOT NULL,
   PRIMARY KEY  (`id`),
   FULLTEXT KEY `txt` (`txt`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC

this because I should convert all characters to utf8 and I would convert
only the special one! For example I would like to do:
INSERT INTO books (txt) VALUES('exa \xC3\xAE mple');

but this will result in: "exa xC3xAE mple"!

I know that I can do:
INSERT INTO books (txt) VALUES(concat('exa', convert(0xC3AE using utf8)
,'mple'));
but I need a way to write this query without the use of concat (like the
first example) by converting special characters in a format understood by
mysql as UTF8 and preserving the others characters!
Is there a way?

Thanks,
Devy

Thread
mysql and utf8devy22 Jan