é = é
Moderator: General Moderators
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Also make sure you tell the browser that the page being returned is encoded as UTF-8
Code: Select all
<?php
header('Content-type: text/html; charset=utf-8');
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
.....- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
I recommend you read my article on UTF-8 to understand what this charset business is all about. Interesting stuff and not too difficult to figure out.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
Ah, well i wonder why it doesnt work... Let me answer your questions.
A few things to ask:
1. Is the form submission page in UTF-8?
Yes, I'm using php header and the characters are printing to the page properly
2. Is the MySQL column's encoding UTF-8?
Yes, I set the entire table to utf-8
3. How are you setting the connection encoding?
Not sure what this means, i'm just connecting using standard connection string.
Also to note, I print out the query, and it is showing the correct character in the insert statement, so i assume it is something with mysql. I'm also using innodb, if that makes a difference
A few things to ask:
1. Is the form submission page in UTF-8?
Yes, I'm using php header and the characters are printing to the page properly
2. Is the MySQL column's encoding UTF-8?
Yes, I set the entire table to utf-8
3. How are you setting the connection encoding?
Not sure what this means, i'm just connecting using standard connection string.
Also to note, I print out the query, and it is showing the correct character in the insert statement, so i assume it is something with mysql. I'm also using innodb, if that makes a difference
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
For the sake of saving you some more pain later on, I'll inform you that PHP doesn't (yet) natively support UTF8... this problem will show itself when you begin using built-in string function on multi-byte strings. The mb_string extension is made for this purpose.
Nice, thanks a lot!
aaronhall wrote:For the sake of saving you some more pain later on, I'll inform you that PHP doesn't (yet) natively support UTF8... this problem will show itself when you begin using built-in string function on multi-byte strings. The mb_string extension is made for this purpose.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
I would recommend using phputf8 rather than mb_string directly. phputf8 contains fast, pure-PHP implementations of the string functions for when mb_string isn't available, and uses mb_string when it is.