Terminal and vim Chinese coding problem

Source: Internet
Author: User
Tags locale

A. Terminal Chinese display garbled

Some netizens said to modify/var/lib/locales/supported.d/locale and/etc/default/locale It's all right, but if multiple people share a machine, there's no root authority. This is obviously undesirable. Now we recommend a change in your own host directory to handle the Chinese display garbled problem

    • Edit. bashrc file
  vim ~/.bashrc
    • At the end of the add
  export LANG=zh_CN.UTF-8  export LC_CTYPE="zh_CN.UTF-8"
    • Enable
  source ~/.bashrc

Terminal display garbled, solved.

Two. Vim Chinese display garbled

And the same as above. Modify the. vimrc file in the host directory to

    1. Vim ~/.VIMRC
  set encoding=utf-8                                    "设置gvim内部编码  set fileencoding=utf-8 "设置当前文件编码  set fileencodings=ucs-bom,utf-8,gbk,cp936,latin-1 "设置支持打开的文件的编码
three. Link MySQL in the terminal sometimes it will show garbled

The general terminal can display the Chinese, after the connection MySQL display will be normal but also will appear garbled this time must set up
1. Use set names UTF8;

  set names utf8;

2. Another way

‘character_set_%‘;查看校对规则系统变量:show variables like ‘collation_%‘;字符集系统变量介绍:character_set_server:默认的内部操作字符集character_set_client:客户端来源数据使用的字符集character_set_connection:连接层字符集character_set_results:查询结果字符集character_set_database:当前选中数据库的默认字符集character_set_system:系统元数据(字段名等)字符集

实现方式 1

my.cnf在[mysqld]下添加 default-character-set=utf8 在[client]下添加 default-character-set=utf8

Terminal and vim Chinese coding problem

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.