Re: entity euro hurts

Jean-Michel Hiver <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.petal
Message-ID <[email protected]>
OK, I have a few insights on your problem.

>- prova.xhtml: doesn't contain any € or &euro; entity, so the &oslash;
>in København appears correctly. &nbsp; is replaced with a blank (why,
>by the way?)
>
It should be replaced by a "Non Breakable SPace" character. This is what 
&nbsp; means.
A &nbsp; furiously looks like a space...

>- prova2.xhtml: contains &euro;, which causes every entity to appear
>messed up.
>
The problem is the following:

In MKDoc/XML/Decode/XHTML.pm, euro points to the decimal value 8364. 
Since this is a unicode high value, Perl has to upgrade all your strings 
to unicode. Hence, whenever you use &euro; symbol the resulting string 
will be UTF-8 rather than latin1.

If you want to be sure that your template is _ALWAYS_ latin1, you have 
to use the 'Encode' module as follows:

use Encode;
my $string = $template->process (%stuff);
$string = Encode::encode ('ISO-8859-1', $string);


>- prova3.xhtml: contains €;, which causes every entity to appear
>messed up (except actually for the € itself, which remains as it
>but I just can't see it the browser (console only).
>
I don't know which character you used for prova3.xhtml, but it appears 
very broken. I open the file in mozilla and wether I use latin-1 or 
UTF-8 to view your example, it doesn't work properly. I suspect this 
third template is broken.

>If I use an ø instead of &oslash for København that is printed just
>fine regardless of what I do with Euro. The problems come when I
>use entities in the &entityname; form. Moreover, &nbsp; never works
>as it should. ;-)
>
Actually it does. It simply replaces it with its corresponding character.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.