UTF-8 support on Windows Console

Source: Internet
Author: User
Source: http://blog.csdn.net/zhubc/article/details/7293376 I recently learned the go language and found that the strings returned after some library functions fail to be called are garbled and strange. So I wrote the simplestProgramTo reproduce this problem:

Func main (){
_, Err: = OS. Open ("None-exist-file ")
If Err! = Nil {
FMT. println (ERR)
}

 

} Compilation and running are all normal, but the output is garbled: Open none-exist-file: too many characters. Why is the optimized version too many characters? The reason is that the go language outputs in UTF-8 encoding, and the windows Console does not support UTF-8 by default. The solution is to change the code page. Use the command chcp to display the current code page without adding any parameters. Change code page to 65001. In addition, the font should be changed to Lucia console. Such changes may cause garbled characters in other programs that do not use UTF-8 encoding. Some related links: Https://groups.google.com/forum! Topic/golang-Nuts/whpwnhbrmfm/discussion

Https://groups.google.com/group/golang-nuts/browse_thread/thread/cf9727737e5b4a00/d0e9d4dc975e875b? Lnk = GST & Q = messy + code # d0e9d4dc975e875b Http://hi.baidu.com/edeed/blog/item/2e99a14440bd8884b2b7dcb1.html Http://blog.codingnow.com/2008/12/utf-8_replacement.html

 

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.