PDA

View Full Version : Character Encoding Fun! ...help



bernk
January 16th, 2008, 12:33 AM
I'm having some trouble with character encoding on a website I'm developing.

I have characters like apostrophes, which were copied and pasted from Word docs, and foreign characters like é and ñ showing up all weird.

Here is an example:

today’s instead of today's

On my local MAMP server this does not happen. The problem is that the client's server is set to a non UTF-8 default charset. I have declared UTF-8 as the charset in the head...but this doesn't seem to do anything.

Anyone have any ideas?

simplistik
January 16th, 2008, 09:19 AM
make sure ALL fields in your DB are defined as utf8, make sure the table defaults at utf8, and make sure all the input you're inserting is utf8. You can force the utf8 insertion by doing


mysql_query('SET NAMES utf8');

note all this will only affect new entries and not existing ones.

you can also force it in the mysql config file


init-connect='SET NAMES utf8'

bernk
February 6th, 2008, 08:15 AM
It's actually not even a dynamic website which leaves me even more puzzled. You can have a look here: http://diproinduca.com/es/

I know that the server's default charset is iso-8859-1, I would like to change it to utf8 but I don't know how and I don't even know who the hosting company is!

Shouldn't this line in the head change the charset on a per-page basis?


<meta http-equiv="content-type" content="text/html; charset=utf-8">

icio
February 6th, 2008, 03:14 PM
Either what's happening is when you transfered the file from windows to linux over FTP the file has become funnied due to the character set or apache is outputing in a strange form.