NYCPHP Meetup

NYPHP.org

[nycphp-talk] I think this is an encoding issue?

Michael Sims jellicle at gmail.com
Wed Oct 17 16:21:58 EDT 2007


On October 17, 2007, Kenneth Downs wrote:
> I'm wondering if somebody knows whats up here.
>
> I'm writing does in OO.org.  Then I export them to xhtml.  Those files I
> parse with PHP and output HTML.
>
> On my laptop this works out just fine.  But on the production server you
> will see problem squiggly stuff instead of double-quotes, as on this
> page:
>
> http://www.andromeda-project.org/pages/cms/Making+Hyperlinks
>
> Can somebody give me a clue where to start Googling on this?

When that page is sent, the web server is telling my browser that it's in 
ISO-8859-1.  It isn't.  It's UTF-8.  For Firefox, choose View, Character 
Encoding, UTF-8, and suddenly the page will be rendered correctly, because 
you told your browser to ignore what the webserver told it and render the 
page in UTF-8.

If I look at the headers that the webserver sent with the page, I see:
-------------------------------
Date: Wed, 17 Oct 2007 20:07:32 GMT
Server: Apache
X-Powered-By: PHP/5.2.2-pl1-gentoo
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private
Pragma: no-cache
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1

200 OK
--------------------------------
See that second to last line?  That's wrong (as in, it doesn't match the 
page you're serving).

So either you need to write your app in ISO-8859-1, or you need to tell your 
webserver to serve the proper header.  You can do it in Apache or in PHP.  
Here's a page of useful info:

http://www.w3.org/International/O-HTTP-charset

Probably the server on your laptop is configured slightly differently than 
the production server.

What *I* would do to solve this problem is get rid of the fancy curly quotes 
altogether.  They are nothing but trouble.  While curly quotes in books 
(dialogue) are nice for readability, where you're using them they're 
definitely wrong.  That is, if you write:

<A HREF= curly quote http://yahoo.com curly quote >

this is not correct HTML.  HTML calls for the double-tick mark, not whatever 
the curly quote character is, so if you cut-and-paste that into an HTML 
document, it won't parse.  You can turn off the curly quotes in 
OpenOffice's options, so that it won't auto-convert the double-tick mark 
for you anymore.

Michael Sims




More information about the talk mailing list