Re: Print Spanish characters in Perl?



On 2008-06-21 00:12, Ben Bullock <benkasminbullock@xxxxxxxxx> wrote:
On Fri, 20 Jun 2008 04:37:34 +0000, Jürgen Exner wrote:
DanB <dbxxxxxxx@xxxxxxxxx> wrote:
I am trying to build a set of Spanish flash cards using TK, and I
need to be able to display the accented characters. I know that I
need to specify them in some unicode besides utf-8,

Actually, you don't. Just put them into your code in your favourite
editor and treat them like any ASCII character.

I suggest *not* doing this, but

use utf8;

and ensure that your file is saved in the UTF-8 format.

I fully agree with that.

[...]
and always specify the output encoding you want:

Since the OP wrote that he's using Perl/Tk, this shouldn't be necessary
- Perl/Tk should know how to display characters in perls internal
encoding. I expanded smallpond's script a bit:

#!/usr/bin/perl
use utf8;
use Tk;

my $win = new MainWindow(-title=>"Cómo está?");
my $frm = $win->Frame(-background => 'blue')->pack(-side => 'top');
my $label = $frm->Label(-text => '¡Hola!')->pack(-side => 'left');
my $label = $frm->Label(-text => 'Cómo está?')->pack(-side => 'left');
my $label = $frm->Label(-text => '75 €')->pack(-side => 'left');

MainLoop;
__END__

and it works fine for me. (I don't normally use Perl/Tk, so there may be
some gotchas I'm not aware of)

hp

.



Relevant Pages

  • Re: Special Characters in Query String
    ... I've had numerous problems with utf-8, ... in common characters in spanish not geting displayed. ... > available for encoding of characters. ... > If you can display your characters with ISO-8859-1, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Open html as source
    ... Word X -- Word X can't display most Unicode. ... characters as two symbols, so I suppose it forgot that it's UTF8. ... Choose UTF-8 at that point. ...
    (microsoft.public.mac.office.word)
  • Re: Unicode-based FreeBSD
    ... maps UTF-8 to 256 characters it is actually able to display. ... Or, in other words, always map from UTF-8. ... There are many applications that do not yet support UTF-8. ...
    (freebsd-current)
  • Problems with UTF8. Unicode, ADO and MySQL
    ... is stored in utf-8 format in order to accomodate for a wide range of ... W2003 server, making no changes, and then try to display the text from ... for non latin characters. ... seems to have little effect) and I have saved all my asp files in utf-8 ...
    (microsoft.public.data.ado)
  • Re: Print Spanish characters in Perl?
    ... be able to display the accented characters. ... I know that I need to specify ... saving as UTF-8, then including the text in an HTML page but forgetting ... ISO-Latin-1 and the non-ASCII characters will be messed up, ...
    (comp.lang.perl.misc)