Page 1 of 1

How to use utf-8?

Posted: Fri Nov 17, 2006 10:33 pm
by pedrotuga
Hey there... i am working on this website that has text in many languages.
I think i have to use UTF-8 in order to be abre to displiay all kinds of character right?

Ok, first of all, the html header... i belive i should change the charsef to "UTF8", is it all it takes on the html?

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	
         ...

</head>
then... the database table. Data outputed comes from only on table in the DB, i use latin1_swedish_ci i think i should change to utf8_unicode_ci if that's not necessary for some reason, or if there is any issues on just going and changing the table colation, please let me know, i red somewhere that utf is compatible with ascii.

Then, my biggest doubt: the sql strings parsing.
I fetch data from POST and i donta have magic_quotes_gpc on. Should i just parse any data inserted in the database with mysql_real_escape_string() then just output it as whenever necessary?

Posted: Fri Nov 17, 2006 11:57 pm
by feyd
Yes. Yes. Yes. And yes.

Make sure to specify utf8 in a header() too.

Re: How to use utf-8?

Posted: Sat Nov 18, 2006 6:51 am
by Chris Corbyn
pedrotuga wrote:i belive i should change the charsef to "UTF8", is it all it takes on the html?
I'm not sure it matters but "utf-8" Notice the hyphen? It probably doesn't matter though. You can do this at a server level too but meta tags are more portable.

Posted: Sat Nov 18, 2006 5:42 pm
by Ambush Commander
Before we go any further, a few questions:

1. What version is MySQL?
2. Do you have iconv installed?