How to use utf-8?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

How to use utf-8?

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Yes. Yes. Yes. And yes.

Make sure to specify utf8 in a header() too.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: How to use utf-8?

Post 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.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Before we go any further, a few questions:

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