perl-unicode

Re: UTF-8 case conversion

2003-09-03 05:30:06
On Wed, 3 Sep 2003 13:05:21 +0200 (CEST), 
sigfrid(_dot_)lundberg(_at_)lub(_dot_)lu(_dot_)se said:

  > I wrote a small script (see below), trying to transform ÖRJAN
  > LUNDSTRÖM into Örjan Lundström, but it seems to fail, probably because
  > of locale related problems. My question is then simply. How do I do
  > this then?

Do not leave filehandles in some dubious default state. Tell perl what
you expect and what you want to see on each and every filehandle.

  > Sigfrid

  > ----------
  > Test script:


  > #!/usr/bin/perl -w

  > use strict;
  > use Encode 'from_to';

  > my $orjan = 'ÖRJAN';
  > my $lundstrom = 'LUNDSTRÖM';

  > print $orjan . ' ' . $lundstrom . "\n";

  > from_to $orjan,'latin1','utf-8';
  > from_to  $lundstrom,'latin1','utf-8';

Add this and you're there:

binmode STDOUT, ":utf8";

  > print $orjan . ' ' . $lundstrom . "\n";

  > print ucfirst( lc $orjan ) . ' ' . ucfirst (lc $lundstrom ) . "\n";


-- 
andreas

<Prev in Thread] Current Thread [Next in Thread>