On Sat, Jan 29, 2011 at 9:46 PM, Shawn H Corey <shawnhco...@gmail.com> wrote:
> On 11-01-29 03:27 AM, xiaolan wrote:
>>
>> Hello,
>>
>> I'm not much sure what's the difference between the two statements below?
>>
>> use encoding 'utf8';
>> use utf8;
>>
>> I have read their documents but not very understandful.
>>
>> Thanks.
>>
>
> `use utf8;` tells the compiler that the script is written in UTF-8. That's
> all it does.
>
> `use encoding 'utf8'` tells it the srcipt is in UTF-8, its literal strings
> are in UTF-8, and STDIN, STDOUT, and DATA are in UTF-8.
>
> $ perl -Mutf8 -e'print"\x{2022}\n";'
> Wide character in print at -e line 1.
> •
> $ perl -Mencoding=utf8 -e'print"\x{2022}\n";'
> •
>
> The second one does not complain about a wide character since STDOUT has
> been change to UTF-8.
>

Thanks for this excellent answer.

Regards.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to