Windows, Gvim Edit, Python2 application garbled problem

Source: Internet
Author: User

Windows,python2 environment, when GVIM is configured with set Fileencoding=utf-8, the new file is encoded as Utf-8.

0 UTF-8 encoding can be used if the code does not contain Chinese, or if it contains only Chinese comments. Just add #-*-coding:utf-8-*-to the file header. You can use the command in Gvim: set fileencoding to see how the document is encoded, and if it is not utf-8, you can set it using the command: Set Fileencoding=utf-8.

0 if the code body contains Chinese, the Utf-8 encoding is not available because the default Chinese encoding method for Windows is GBK, so if you encode in Utf-8, the execution results are garbled. At this time to use GBK encoding, that is, the file header plus #-*-CODING:GBK-*-, in addition to the file encoding to GBK, the use of commands in Gvim: Set FILEENCODING=GBK can, note, set to save after completion, with the command: set fileencoding view file encoding method can get results for fileencoding=cp936, note that this result is correct, because GBK is an extension of cp936.

Windows, Gvim Edit, Python2 application garbled problem

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.