Wongy
asked on
Using Asian (Chinese, Japanese and Korean) and accentuated characters with PHP/MySQL
Hi,
I need to develop a web-based application where users could enter Asian characters (Chinese, Japanese and Korean) and accentuated characters (é, à, è, ...) in the same field.
The database used is MySQL. The server OS is Linux. The clients' OS is usually Windows.
I've already tried UTF and the different things proposed on the Internet, but I can not make it work.
What should be the way to proceed?
Thanks for your help.
I need to develop a web-based application where users could enter Asian characters (Chinese, Japanese and Korean) and accentuated characters (é, à, è, ...) in the same field.
The database used is MySQL. The server OS is Linux. The clients' OS is usually Windows.
I've already tried UTF and the different things proposed on the Internet, but I can not make it work.
What should be the way to proceed?
Thanks for your help.
when u save your file , select ENCODING TYPE = UTF-8, just try it
ASKER
Which file? Since the content is dynamically generated by the users (like in a text area).
theses lines should be present in your my.cnf
[mysql]
default-character-set = utf8
[mysql]
character-set-server = utf8
collation-server = utf8_general_ci
and your tables and columns should use utf8 character set and utf8_general_ci as collation
[mysql]
default-character-set = utf8
[mysql]
character-set-server = utf8
collation-server = utf8_general_ci
and your tables and columns should use utf8 character set and utf8_general_ci as collation
ASKER
Totally confused...
Here is what I get:
I've changed the character set of the column, table and database to utf8_general_ci.
I've made a test with PhpMyAdmin: I succeeded to enter Asian characters and they were properly displayed (still in PhpMyAdmin). But they were still displayed as ?????? in my own application.
I put this line in the beginning of my page: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
By doing this, I could enter Asian characters via my page and could properly see them after posting the data if I display the data in the text area. Otherwise, if displayed in a table (td), I get gibberish.
What is the problem?
Here is what I get:
I've changed the character set of the column, table and database to utf8_general_ci.
I've made a test with PhpMyAdmin: I succeeded to enter Asian characters and they were properly displayed (still in PhpMyAdmin). But they were still displayed as ?????? in my own application.
I put this line in the beginning of my page: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
By doing this, I could enter Asian characters via my page and could properly see them after posting the data if I display the data in the text area. Otherwise, if displayed in a table (td), I get gibberish.
What is the problem?
you must add a header before sending your html. using php this can be done by :
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/html; charset=utf-8');
ASKER
Isn't this already done when I put <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
at the beginning of the page?
at the beginning of the page?
not enough, most browsers use header information instead of meta
ASKER
I tried it.
I've put this line right before <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> but still does not work.
I've put this line right before <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> but still does not work.
not this way. if you use php you should add at the beginning of you php page
<?php
header('Content-Type: text/html; charset=utf-8');
<?php
header('Content-Type: text/html; charset=utf-8');
ASKER
Of course with the right syntax.
This is what I've put:
<?php header('Content-Type: text/html; charset=utf-8');?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
The weird thing is that the text is properly displayed in a text area, but not in a table.
This is what I've put:
<?php header('Content-Type: text/html; charset=utf-8');?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
The weird thing is that the text is properly displayed in a text area, but not in a table.
i think i have forgotten one thing, you should add :
mysql_query("SET NAMES 'utf8'", $db)
just after the database connection.
mysql_query("SET NAMES 'utf8'", $db)
just after the database connection.
ASKER
Still not good...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.