Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] unicode and Perl- how to pass command line unicodearguments



On Date: Mon, 13 Feb 2006 12:11:00 +0900, David Riggs <dariggs@example.com> wrote:
> David E replied to David Riggs:
> 
> On Date: Sun, 12 Feb 2006 17:30:00 +0900, David Riggs 
> <dariggs@example.com> wrote:
>  > Does anyone know how to pass real unicode kanji to perl on the command
>  > line? (Not just bytes that appear as kanji but are passed on as 
> bytes.)---
> 
> --Reply:
> ---You might need to do
> ---  utf8::decode($whatever)
> ---on the args you read in.
> 
> --More info here:
> ---http://search.cpan.org/~jhi/perl-5.8.0/pod/perluniintro.pod
> Thanks David. I got something similar to work (follow your link):
> 
>   use Encode 'decode_utf8';
>      $Unicode = decode_utf8($bytes);
> 
> Somehow your suggested utf8::decode($x) only returns a "1", presumably 
> for success, and I do not see how to get it to return the value.

utf8::decode does its work in place on $x.

Here's the blurbo from perldoc utf8

 * utf8::decode($string)
     Attempts to convert in‐place the octet sequence in UTF‐X to the
    corresponding character sequence.  The UTF-8 flag is turned
    on only if the source string contains multiple‐byte UTF‐X
    characters.  If $string is invalid as UTF‐X, returns
    false; otherwise returns true.

TTMMTOHWTDI: There are too many more than one hundred ways to do it. 
Or something like that.

Dave

> 
> By the way, I find that perl m/// and s/// just do not work on kanji 
> unicode typed directly into the expression. But if you set the kanji 
> into a variable, and then immediately use it one of those operators, its 
> fine.
> 
> Very mystifying.
> 
> Thanks for the help, now that I realize these two additional things I 
> have perl unicoding away.
> 
> And I thought perl was supposed to just work with unicode!
> 
> 
> David Riggs
> 
> -- 
> The TLUG server is hosted by Open Source Development Lab Japan.
> http://www.osdl.jp/
> 
> To unsubscribe from this mailing list, 
> please see the instructions at http://www.tlug.jp/list.html

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links