Thanks Jeremy a lot, it did help.
You were right; I've been entering data correctly. I only could not see it the right way. After a little of tests, I finally figured it out how to do this and I'm going to tell it here so if any one had my problem, so he can use this.


================================================
Before saying any of the solution, let me explain the situation. I'm using MySQL 4.1.1a-alpha-win and I did not touch any of the configuration files (you know, like my.ini). All I did was using queries, and that's big point I think since you can not always reach configuration files. I'm trying to enter UTF-8 data to data base and retrieve them back, using the new capabilities of multi-lingual of the MySQL. These new capabilities contains Full-Text search on UTF-8 fields too.
First create a table like this:


CREATE TABLE my_table (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
my_field VARCHAR( 100 ) CHARACTER SET utf8,
);

Entering data is so simple, only a little change is enough; this change is to put a "_utf8" before your string:

INSERT INTO my_table (my_field) VALUES ( _utf8 'string_encoded_in_utf8' );

After that, when you want to retrieve data from data base, there it comes the problem that took me a week. After you made the connection to data base and before executing your select query, use the following query:

SET CHARACTER SET utf8;

And then, with the same connection, run your select query like this:

SELECT my_field FROM my_table;

Which is an ordinary one, of course.
That was all.
================================================

The only problem with this solution is that "SET CHARACTER SET" query can not be run before select query always. I mean consider interfaces like phpMyAdmin, in a web host they won't let you change its code, neither the configuration files of MySQL. Then how can we make MySQL to translate strings to UTF-8? There is a one way and that's making it the default character set which completely make sense since it's an international character set. But I'm sure it's up to MySQL's sponsors.

Thank you Jeremy, it was all your help. You found me after I've been lost.
Mehran Ziadloo

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail



-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to