OS X Terminal UTF-8 issues

后端 未结 11 2203
忘了有多久
忘了有多久 2020-11-27 14:56

Okay, so I finally got myself a MacBook Air after 15 years of linux. And before I got it my big concern was UTF-8 support because no matter if I get files sent to me from wi

相关标签:
11条回答
  • 2020-11-27 15:21

    Unfortunately, the Preferences dialog is not always very helpful, but by tweaking around you should be able to get everything working.

    To be able to type Swedish characters in Terminal, add the following lines to your ~/.inputrc (most likely you must create this file):

    set input-meta on
    set output-meta on
    set convert-meta off
    

    This should do the work both with utf8 and other codings in bash, nano and many other programs. Some programs, like tmux, also depends on the locale. Then, adding for instance export LC_ALL=en_US.UTF-8 to your ~/.profile file should help, but keep in mind that a few (mainly obscure) programs require a standard locale, so if you have trouble running or compiling a program, try going back to LC_ALL=C.

    Some references that may be helpful:

    • http://homepage.mac.com/thgewecke/mlingos9.html#unicode
    • http://hints.macworld.com/article.php?story=20060825071728278
    0 讨论(0)
  • 2020-11-27 15:24

    Go to Terminal -> Preferences -> Advanced (Tab) go down to International and select Unicode (UTF-8) as Character Encoding.

    And tick Set locale environment variables on startup.

    0 讨论(0)
  • 2020-11-27 15:26

    Short versatile answer (fits to other national languages, even Lithuanian or Russian)

    • open Terminal
    • edit .profile in home directory - nano .profile or in Catalina or newer nano .zshenv
    • add line export LC_ALL=en_US.UTF-8
    • press Ctrl+x and Y (exit and save)

    This solved for me even small country rare national characters. You may need to close and open Terminal to make changes effective.

    Also if you like Linux behavior (use lot of Alt shortcuts like Alt+. or Alt+, in mc) then you should disable Mac style Option key function: Terminal->Preferences->Profiles->Keyboard and check box: Use Option as Meta key

    0 讨论(0)
  • 2020-11-27 15:29

    To make nano work as you want it to, try:

    export LANG="UTF-8"
    

    Or get a newer version of nano via MacPorts:

    # cf. http://www.macports.org/install.php
    port info nano
    port variants nano
    sudo port install nano +utf8 +color +no_wrap
    

    With respect to ssh & UTF-8 issues comment out SendEnv LANG LC_* in /etc/ssh_config.

    See: Terminal in OS X Lion: can't write åäö on remote machine

    0 讨论(0)
  • 2020-11-27 15:31

    Try

    1. Having a Powerline compatible font installed https://github.com/powerline/fonts
    2. Setting these ENV vars in .zshrc or .bashrc:
    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"
    
    0 讨论(0)
  • 2020-11-27 15:37

    My terminal was just acting silly, not printing out åäö. I found (and set) this setting: enter image description here

    Under Terminal -> Preferences... -> Profiles -> Advanced.

    Seems to have fixed my problem.

    0 讨论(0)
提交回复
热议问题