[htmltmpl] UTF-8 and ESCAPE=HTML
Brought to you by:
samtregar
From: Mark A. <pe...@ma...> - 2015-05-07 08:25:41
|
Question about TMPL_VAR and ESCAPE=HTML When using content such as ñ and a Chinese character like “字” they display just fine in the browser when we use a tag like: <!— TMPL_VAR NAME —> However, if we use: <!— TMPL_VAR NAME ESCAPE=“HTML” —> the values do not display as their character but rather the HTML encoded value: According to the documentation of HTML::Template escape HTML should only escape 5 characters: Replaces the following characters with their HTML entity equivalent: &, ", ', <, > However, it appears that it is doing more than just replacing those 5 characters with their HTML entity equivalent. It seems to be changing UTF-8 characters as well. When calling HTML::Template->new() we are specifying: utf8 => 1 The server is sending a Content-Type header of text/html; charset=UTF-8 and we also employ the meta-tag for specifying the charset. The HTML for the input tag looks like this: <input type=“text” name=“middlename” value=“<!— TMPL_VAR NAME=‘middlename’ ESCAPE=HTML—>” title=“Middle Name” /> Is this expected behavior? Is there a work-around? At this point the only solution I see is to do my own escaping of just any double quotes and then use the value in my TMPL_VAR without HTML escaping. By the way, we’ve been using HTML::Template for years and it’s become a key part of our software. We appreciate all that’s been done with it so far. — Mark |