[solved] exporting data in utf-8 using the "SELECT...OUTFILE" command
Posted by:
e ponyo
Date: July 31, 2009 11:26AM
Hi,
I have a table whose charset is utf-8 :
create table index(
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
nom VARCHAR(255) NOT NULL,
)DEFAULT CHARACTER SET=utf8;
I want to export it using the command "SELECT...OUTFILE" . To do this, I use this PHP CODE :
mysql_query("set names 'utf8'");
$var = mysql_query('show variables');
while ($res = mysql_fetch_row ($var)){
echo ("<p>$res[0] : $res[1]</p>");
}
// The last loop displays the following information :
// character_set_client : utf8
// character_set_connection : utf8
// character_set_database : latin1
// character_set_filesystem : binary
// character_set_results : utf8
// character_set_server : latin1
// character_set_system : utf8
// character_sets_dir : /usr/share/mysql/charsets/
// collation_connection : utf8_general_ci
// collation_database : latin1_swedish_ci
// collation_server : latin1_swedish_ci
mysql_query('SELECT * FROM index INTO OUTFILE '/tmp/index.txt');
My problem is that the diacritics don't print well in the output file, for example :
22 édition
instead of :
22 édition
I've checked the encoding of the output file, using the shell command "file" and it says the file is encoded in utf8.
Also, when I interact with the database from the terminal (which is set to utf-8), the diacritics are displayed correctly.
I 've read the "SELECT..OUTFILE" documentation, searched several forums, but I still don't understand why it is not working.
Anyone has an idea ?
Thank you.
Edited 1 time(s). Last edit at 08/03/2009 06:22AM by e ponyo.
Subject
Views
Written By
Posted
[solved] exporting data in utf-8 using the "SELECT...OUTFILE" command
20145
July 31, 2009 11:26AM
6128
August 01, 2009 06:49AM
5704
August 03, 2009 06:22AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.