In OS X Lion, LANG is not set to UTF-8, how to fix it?

后端 未结 5 1439
离开以前
离开以前 2020-11-28 17:25

I try to setup postgress in OS X Lion, and find that is not correctly setup the LOCALE environment var.

This is what is set:

LANG=
LC_COLLATE=\"C\"
L         


        
相关标签:
5条回答
  • 2020-11-28 18:05

    I noticed the exact same issue when logging onto servers running Red Hat from an OSX Lion machine.

    Try adding or editing the ~/.profile file for it to correctly export your locale settings upon initiating a new session.

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

    These two lines added to the file should suffice to set the locale [replace en_US for your desired locale, and check beforehand that it is indeed installed on your system (locale -a)].

    After that, you can start a new session and check using locale:

    $ locale
    

    The following should be the output:

    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-28 18:14

    This is a headbreaker for a long time. I see now it's OSX.. i change it system-wide and it works perfect

    When i add this the LANG in Centos6 and Fedora is also my preferred LANG. You can also "uncheck" export or set locale in terminal settings (OSX) /etc/profile

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

    0 讨论(0)
  • 2020-11-28 18:25

    I recently had the same issue on OS X Sierra with bash shell, and thanks to answers above I only had to edit the file

    ~/.bash_profile 
    

    and append those lines

    export LC_ALL=en_US.UTF-8
    export LANG=en_US.UTF-8
    
    0 讨论(0)
  • 2020-11-28 18:25

    if you have zsh installed you can also update ~/.zprofile with

    if [[ -z "$LC_ALL" ]]; then
      export LC_ALL='en_US.UTF-8'
    fi
    

    and check the output using the locale cmd as show above

    ❯ locale                                                                                                                                           
    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-28 18:26

    I had this issue with MacOS High Sierria.

    You can set up locale as well as language to UTF-8 format using below command :

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

    Now in order to check whether locale environment is updated use below command :

    Locale
    

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