tags:

views:

45

answers:

3

I am extracting text from a MySQL database table, collation is set to utf8_general_ci. In PHPMyAdmin, I can see the characters correctly:

"La consiglio fermamente anche perchè ho già acquistato iWrap per il mio:"

But when I extract it myself it prints out this way:

"La consiglio fermamente anche perch� ho gi� acquistato iWrap per il mio:"

How can I make the characters print correctly? Thanks!

A: 

Try using utf8_unicode instead of general.

dannybolabo
The collation is not the issue here.
Hammerite
A: 

use htmlentities and/or utf8_decode

Christian Smorra
why -1? is this bad practice? please let me know
Christian Smorra
+3  A: 
  • Is your script utf8-encoded?
  • Is the browser displaying it as utf8?
  • Is your mysql connection's charset set to utf8?
  • Is phpmyadmin's connection's charset set to utf8?

You can check the first in your editor.
You can check the second one in your browser (also check the http headers it receives).
You can set a mysql connection to use utf8 with a simple SET NAMES 'utf8'; query.
Phpmyadmin's charset is displayed somewhere on it's index page.

Maerlyn
Made these changes: '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' in head, made a SET NAMES 'utf8' query right after my database connection. Not fixed yet... don't know how to check if my script is utf8-encoded. Rapid PHP 2008?
Tim Chaves
@Tim I am not familiar with that editor, maybe someone else. Check @NullUserException's comment under your opening post to make sure your data is stored as utf8.
Maerlyn
Thanks. I was an idiot and the SET NAMES query was not actually running. Once it did it fixed all.
Tim Chaves