Support for character encoding in Perl scripts

Source: Internet
Author: User
Tags perl script

# Enable the Perl program to support utf8 wide character encoding. If you do not add the following lines to print Chinese characters, the wide character in print warning or error will appear.
Use utf8;
Binmode (stdin, ': encoding (utf8 )');
Binmode (stdout, ': encoding (utf8 )');
Binmode (stderr, ': encoding (utf8 )');
When a Perl script processes characters such as Chinese characters, sometimes the data read from the file is a bytecode and must be decoded before it can be correctly displayed. Use the encode module for processing.
Use encode;
# $ Str1 indicates the data obtained from UTF-8 encoded data stored in a file or database.
My $ str0 = decode ("utf8", $ str1 );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.