Robin Berjon wrote:
Christopher H. Laco wrote:

On a side note, L::C::Format can just return the symbol,, but it's unclear what encoding it is actually in. That is why I was shooting for the &#x0000 encoding method instead.


Have you tried that option of getting just the character? XSP happens in Perl land (it's just a way of generating Perl code after all) and it's therefore highly likely that it'll play well with other modules. Especially if you're running 5.8.

As a rule of thumb there are only two situations when escaping should be used: when authoring a document, and when writing a serializer. In any other situation you're working with a data model instead of an actual representation, and therefore escaping should never be necessary. If it is something smells bad in the system, and you know you'll hit trouble at some point.


After some tinkering, here's what I've got.

This is the original code called by TaglibHelper for the simple case of just getting the currency symbol in AxKit::XSP::Currency:

sub symbol {
    my ($code, $options) = @_;

    $code    ||= 'USD';
    $options ||= 'SYM_HTML';

    eval '$options = ' . $options;

    return currency_symbol($code, $options);
};

When called as: <currency:symbol code="JPY" options="SYM_UTF"/> I get ? in the resultant XML.

No use uft8, no special handling. If I just add 'use utf8' to the taglib, the same things happens; I get ? in the resultant XML.

With some tweaking, I ended up with this:

use utf8;
...
sub symbol {
    my ($code, $options) = @_;

    $code    ||= 'USD';
    $options ||= 'SYM_HTML';

    eval '$options = ' . $options;

    my $symbol = currency_symbol($code, $options);
    utf8::upgrade($symbol);

    return $symbol;
};

I'm not sure at all if this is the right thing to do, but it works.
Now calling <currency:symbol code="JPY" options="SYM_UTF"/> now yields the expected: �

Now I have more questions than answers. What do I do in situations where utf8 pragma isn't there? And what about people who really want to use the FTM_HTML version instead? How do they deal with the pre-escaped &amp;#x0000 ?

Time to work this into the other methods...

Thanks
-=Chris

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



Reply via email to