I'm tinkering around with the currency formatting options in AxKit::XSP::Currency and Handel and I'm banging my head against the wall trying to figure out the 'proper' way do deal with the 'utf' currency symbols returned by Locale::Currency::Format.

Long story longer, the L::C::F::currency_symbol method can return the UTF version of the currency symbol. I have a method in the AxKit XSP taglibs for the modules above that simply returns the value returned from that method.

sub symbol { my ($code, $options) = @_; $code ||= 'USD'; $options ||= 'SYM_UFT'; eval '$options = ' . $options; return currency_symbol($code, $options); };

With everything declared as UTF-8, it returned ? instead of the symbol. So, after some tinkering, here's what I've learned.

First, in 5.6.1, everything works fine without the need to 'use utf8'. The currency symbol is displayed just fine.

Next, in 5.8.4, the symbol is always displayed as ?. Adding 'use utf8' to the module made no difference. This code however, fixes the problem:

sub symbol { my ($code, $options) = @_; $code ||= 'USD'; $options ||= 'SYM_UFT'; eval '$options = ' . $options; my $symbol = currency_symbol($code, $options); utf8::upgrade($symbol); return $symbol; };

I know a good part of this is blurred by what AxKit does and how it handles utf, but does this seem right to anyone? Are other people having to jump through hoops just to get 5.8.x act like 5.6. used to when it comes to just outputing utf data?

9 times out of 10, stuff just works between 56 and 58 for me. Is this one of those times where they're not the same and I don't understand what in the heck I'm doing? :-)


In reply to UTF8/Unicode Confusion by jk2addict

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.