zoukankan      html  css  js  c++  java
  • Mac连接到Linux上,不能输入中文

    链接地址:

    http://blog.csdn.net/aabbcc456aa/article/details/50681330

     

    服务器是ubuntu,用Mac的iterm2 ssh连上去,终端显示中文乱码,也不能输入中文,然而本地终端可以显示和输入。

    解决方法:

    这种情况一般是终端和服务器的字符集不匹配,MacOSX下默认的是utf8字符集。
    输入locale可以查看字符编码设置情况,而我的对应值是空的。
    因为我在本地和服务器都用zsh替代了bash,而且使用了oh-my-zsh,而默认的.zshrc没有设置为utf-8编码,所以本地和服务器端都要在.zshrc设置,步骤如下,bash对应.bash_profile.bashrc文件。

    1.在终端下输入

    1
    
    vim ~/.zshrc
    

    或者使用其他你喜欢的编辑器编辑~/.zshrc文件

    2.在文件内容末端添加:

    1
    2
    
    export LC_ALL=en_US.UTF-8  
    export LANG=en_US.UTF-8
    

    接着重启一下终端,或者输入source ~/.zshrc使设置生效。

    设置成功的话,在本地和登录到服务器输入locale回车会显示下面内容。

    1
    2
    3
    4
    5
    6
    7
    8
    
    LANG="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_CTYPE="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_ALL="en_US.UTF-8"
    

    这时,中文输入和显示都正常了。

    3.如果设置之后出现以下问题

    -bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
    解决办法:

    1
    2
    3
    
    sudo locale-gen en_US.UTF-8
    
    sudo dpkg-reconfigure locales
    

    解释:

    1
    
    The error "bash: warning: setlocale: LC_ALL: cannot change locale (en_US)" occurs when the remote server does not understand the locale "en_US.UTF-8". The fix is to generate the locale using the command "sudo locale-gen en_US.UTF-8" and update the locale repository to store this locale, such that future connections(ssh) can understand this locale. The command "sudo dpkg-reconfigure locales" updates the local repository with the newly generated locale, i.e en_US.UTF-8.
    

    (大概意思就是服务器上没有安装这个编码的字符集,安装之后设置一下就支持了)

  • 相关阅读:
    win10 L2TP拨号
    Esxi直通板载Sata
    Esxi 增加网卡驱动 生成ISO
    IPMITOOL THRESHOLD 修改
    Reverse Engineering Supermicro IPMI
    Esxi通过RDM直通硬盘
    Centos 安装后优化
    Centos 6安装apache 2.4
    Try Catch Finally 中Finally的代码在什么时候不被执行
    用CutePDF AND GhostScript 生成PDF的处理流
  • 原文地址:https://www.cnblogs.com/qinyan20/p/6225547.html
Copyright © 2011-2022 走看看