Page 1 of 1

é = é

Posted: Fri Mar 23, 2007 8:16 pm
by GeXus
I'm grabbing some data from an rss feed, and it is converting what should be 'é' to 'é' when I actually print it out...

Any idea why this would be?

Posted: Fri Mar 23, 2007 10:13 pm
by Kieran Huggins
sounds like a character encoding thing to me - make sure it's the same all the way through

Posted: Sat Mar 24, 2007 2:33 am
by aaronhall
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>
.....

Posted: Sat Mar 24, 2007 9:36 am
by GeXus
Bingo, that was it.. thanks!

Posted: Sat Mar 24, 2007 12:35 pm
by Ambush Commander
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.

Posted: Sat Mar 24, 2007 8:28 pm
by GeXus
Ambush, that's a good article, thanks.. I do however seem to still be having problems with data being entered in mysql. I set the character set to utf8, however storing the 'é' instead of 'é'

Any ideas?

Thanks!

Posted: Sat Mar 24, 2007 8:33 pm
by Ambush Commander
A few things to ask:

1. Is the form submission page in UTF-8?
2. Is the MySQL column's encoding UTF-8?
3. How are you setting the connection encoding?

Posted: Sat Mar 24, 2007 8:55 pm
by GeXus
Well, reading more of your article i see that mysql v4 does not support character encoding, and i'm on 4.1
hmm.. guess I have to upgrade.

Posted: Sat Mar 24, 2007 8:57 pm
by Ambush Commander
4.0 doesn't support character encoding, but 4.1 does. No upgrading necessary.

Posted: Sun Mar 25, 2007 11:14 am
by GeXus
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

Posted: Sun Mar 25, 2007 12:20 pm
by aaronhall

Posted: Sun Mar 25, 2007 12:43 pm
by GeXus
Ahh, thank you! Works now... what a pain :)

Posted: Sun Mar 25, 2007 1:04 pm
by aaronhall
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.

Posted: Sun Mar 25, 2007 3:05 pm
by GeXus
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.

Posted: Sun Mar 25, 2007 3:10 pm
by Ambush Commander
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.