OS X Terminal UTF-8 issues

后端 未结 11 2248
忘了有多久
忘了有多久 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:38

    The following is a summary of what you need to do under OS X Mavericks (10.9). This is all summarized in

    http://hints.macworld.com/article.php?story=20060825071728278

    1. Go to Terminal->Preferences->Settings->Advanced.

      Under International, make sure the character encoding is set to Unicode (UTF-8).

      Also, and this is key: under Emulation, make sure that Escape non-ASCII input with Control-V is unchecked (i.e. is not set).

      These two settings fix things for Terminal.

    2. Make sure your locale is set to something that ends in .UTF-8. Type locale and look at the LC_CTYPE line. If it doesn't say something like en_US.UTF-8 (the stuff before the dot might change if you are using a non-US-English locale), then in your Bash .profile or .bashrc in your home directory, add a line like this:

      export LC_CTYPE=en_US.UTF-8
      

      This will fix things for command-line programs in general.

    3. Add the following lines to .inputrc in your home directory (create it if necessary):

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

      This makes Bash be eight-bit clean, so it will pass UTF-8 characters in and out without messing with them.

    Keep in mind you will have to restart Bash (e.g. close and reopen the Terminal window) to get it to pay attention to all the settings you make in 2 and 3 above.

提交回复
热议问题