jk2addict has asked for the wisdom of the Perl Monks concerning the following question:
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? :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: UTF8/Unicode Confusion
by dave_the_m (Monsignor) on Mar 20, 2005 at 17:05 UTC | |
by jk2addict (Chaplain) on Mar 20, 2005 at 17:24 UTC | |
by dave_the_m (Monsignor) on Mar 20, 2005 at 23:30 UTC | |
by jk2addict (Chaplain) on Mar 21, 2005 at 01:09 UTC | |
by ysth (Canon) on Mar 21, 2005 at 05:39 UTC | |
| |
by jk2addict (Chaplain) on Mar 20, 2005 at 17:12 UTC | |
|
Re: UTF8/Unicode Confusion
by jk2addict (Chaplain) on Mar 20, 2005 at 23:17 UTC |