[PHPTAL] html entities with phptal
Laurent Bedubourg
lbedubourg at motion-twin.com
Mon Jul 10 18:04:10 CEST 2006
On Mon, 2006-07-10 at 08:51 -0500, Nestor A. Diaz wrote:
> Hello, for some time ago i was waiting for the oportunity to build an
> application with phptal, and i begin to do so this week, i currently
> have a problem with htmlentities, since i write spanish aplications i
> make use of special iso8859-1 character, aáéíóú, so the problems comes
> with the following:
>
> $template->title = "á";
>
> produce the following:
>
> á
>
> So, what is the correct way to process non english characters ? of course i can do this with the following:
>
Hi Nestor,
The "correct" way to process non english characters is to ignore them.
$tpl->setEncoding('ISO-8859-1');
$tpl->title = 'á';
A great feature of PHPTAL is that you do not have to worry about html
escaping. Just set the correct encoding for your application and let
PHPTAL do the work.
You may have to add something like :
<meta
http-equiv="Content-Type"
content="text/html; charset=iso-8859-1"
/>
in your template to ensure that any browser will be able to detect an
probably render the charset.
And if you are a maniac,
<?php
header('Content-type: text/html; charset=iso-8859-1;");
?>
can help too.
If the data you are transmitting to PHPTAL is already encoded, you can
use the "structure" keyword as explained by Joshua.
Last, if your application will have to be internationalized, I strongly
recommend using UTF-8 instead of ISO*. Configuring your text editor and
your database may be difficult depending on the tools you are using but
porting your application to other locales will be easier in many ways.
Please note that the default PHPTAL encoding is UTF-8, if you are not
using it, it is recommended to specify your character encoding as
explained earlier.
Best regards
Laurent
More information about the PHPTAL
mailing list