On 2005.6.16, at 05:13 AM, John Delacour wrote:

> At 4:26 am +0900 16/6/05, Robin wrote:
>
>> I went back to look at perluniintro because I was sure I could >> remember reading that the "use utf8" pragma was no longer needed, >> right under where it says this it continues "Only one case remains >> where an explicit "use utf8" is needed: if your Perl script itself is >> encoded in UTF-8...."
>
> Nevertheless (Perl 5.8.6) if you simply comment
>
> #binmode (DATA,":utf8");
> #binmode (STDOUT,":utf8");
>
> provided your script is UTF-8 encoded, there is no need for 'use > utf8'. The script you posted works fine in that case,

Not a good idea. For the time being, and until UTF-8 is established as the default encoding for perl (should that ever happen), when your source code includes multibyte characters tell perl so.

I suppose, in a context where you have automatic encoding conversion taking place whenever you move code from one environment to another, this rule of thumb would not be a rule of thumb. But otherwise, you want to do what you can to tell the various things that interpret your code what the encoding is. (And blind automatic conversion has its own set of problems.)

>  as does
>
>
> $f = "$ENV{HOME}/junk.txt";
> open F, ">$f";
> print F "月";
> close F;
> open F, $f;
> for (<F>) {/月/ and print}
>
> JD

--
Joel Rees
I've already left the building. You don't really see me here.

Reply via email to