Hi,
I seem to be going round in circles trying to understand when I need to encode to UTF-8 to get special characters to show correctly (specifically the GBP symbol £)
I have a reporting class that formats monetary values with the 'Locale::Currency::Format' module...
My understanding is this module auto converts the currency symbol to Unicode "/x{00A3}" , which according to the codepoint.net site (if I'm reading it correctly), is UTF-16. (00A3)
But I tried to decode as UTF-16 and the encode module just bombs with
So I tried simply encoding to UTF-8 and outputting to HTML and it displays correctly
Great, however, if I then try to output to a CSV text file the browser just hangs and no file is downloaded.
So I removed from the output code
and I get the CSV output but with funny characters...
So I remove both encoding and the binmode output formatting and bingo, I get a GBP pound sign in my CSV.
However, if I remove the encode to UTF-8 before outputting the HTML I get
I'm baffled, do I or don't I need to encode before outputting, what formatting is my string currently, what am I meant to convert it to and when?
your help is appreciated.
1DMF
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
I seem to be going round in circles trying to understand when I need to encode to UTF-8 to get special characters to show correctly (specifically the GBP symbol £)
I have a reporting class that formats monetary values with the 'Locale::Currency::Format' module...
Code:
$my_value = currency_format('gbp', $my_value, FMT_SYMBOL);
My understanding is this module auto converts the currency symbol to Unicode "/x{00A3}" , which according to the codepoint.net site (if I'm reading it correctly), is UTF-16. (00A3)
But I tried to decode as UTF-16 and the encode module just bombs with
"UTF-16:Unrecognised BOM 2249 at C:/Perl/site/lib/Encode.pm line 175."
So I tried simply encoding to UTF-8 and outputting to HTML and it displays correctly
Code:
$self->_encode($my_string, 'UTF-8')
So I removed from the output code
Code:
$iof->binmode(":encoding(UTF-8)");
, so I remove the encode to UTF-8 but keep the binmode output encoding to UTF-8 but that outputs
Which according to codepoint.net is Perl.\xA3
So I remove both encoding and the binmode output formatting and bingo, I get a GBP pound sign in my CSV.
However, if I remove the encode to UTF-8 before outputting the HTML I get
I'm baffled, do I or don't I need to encode before outputting, what formatting is my string currently, what am I meant to convert it to and when?
your help is appreciated.
1DMF
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music