Posted on 2006-06-18 13:43:32-07 by onestone
Write Euro symbol in string?
Hello,
I cannot generate a Euro symbol in a string with WriteExcel. The only thing I get is a square. The goal is to write from a perl script a text like "The spent in € is" direct into a excel worksheet. At the moment I succeed writing 15 different languages into one excel sheet, but this fails if a text contains a euro symbol.
I tried different methods:
my $euro = pack "n", 0x80; $worksheet->write_unicode('A1',$euro);
or
my $map = Unicode::Map->new("ISO-8859-15"); my $utf16 = $map->to_unicode("The spent in € is"); $worksheet->write_unicode('A1', $utf16);
Could anybody help?
Thank you very much!
Onestone
Direct Responses: 2506 | Write a response
Posted on 2006-06-18 16:38:27-07 by jmcnamara in response to 2505
Re: Write Euro symbol in string?

The Euro character is 0x20AC in UTF-16. Here is an example with UTF-16 and UTF-8.

#!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new('euro.xls'); my $worksheet = $workbook->add_worksheet(); my $euro = pack "n", 0x20AC; # UTF-16 Euro $worksheet->write_unicode('A1', $euro); # UTF-8 string in perl 5.8. if ($] >= 5.008) { $euro = chr 0x20AC; $worksheet->write('A3', "This is the euro symbol: $euro"); }
John.
--
Direct Responses: 2509 | Write a response
Posted on 2006-06-18 19:40:16-07 by onestone in response to 2506
Re: Write Euro symbol in string?
Hello John,
thanks a lot. I got it!
Greetings,

Onestone
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.