On 03-01-2009 at 14:41:26 Mikael Andersson <mail.mi...@gmail.com> wrote:

It works fine now, just in case someone else runs into similar trouble this is what I've done.

1. set the encoding for the PHPTAL object
2. Added <?xml version="1.0" encoding="ISO-8859-1"?>
3. Added <meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"/>

Setting 1 isn't necessary with 2 or 3.
Also noticed that I didn't need both 2 and 3, as long as I had one of them
it worked.

Would be great if someone with some encoding know-how could educate me on
the proper way of doing this :-)

IMHO the proper way is to never ever use ISO encodings again ;)

Use UTF-8 (that's PHPTAL's default). You'll be able to use all Swedish 
characters, nice punctuation, and thousands of other symbols. Any decent text 
editor should support UTF-8 (avoid Microsoft Notepad, because it inserts 
invisible BOM character that sometimes causes trouble). [don't forget to 
convert existing files if you switch]


If you don't want UTF-8, then you can use any 8-bit encoding as long as you're 
consistent with its use and declarations everywhere.


You need to tell PHPTAL which encoding you're using ($phptal->setEncoding()) if it's different than UTF-8, and you always need to tell browsers what to expect. It's best to declare encoding in HTTP headers. If you're sending XHTML files as text/html (like everyone does...), then <meta> is OK too.
Don't bother with <?xml?> declaration unless you're generating XML other than 
XHTML (e.g. Atom), or seriously using XHTML without caring about IE compatibility 
(IE6 doesn't like XML declaration).

--
regards, Kornel




_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to