Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OS X Terminal UTF-8 issues

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 windows or mac-clients theres always issues with encoding, while on ubuntu I can be sure that all output no matter what program will produce perfect utf-8 encoded data.

And now on my second day (today) with OS X Im tearing my hair of by frustration. Why?

When I open Nano and type some swedish characters like ÅÄÖ in it, it puts out blank characters at the end of the line (which i guess is the other byte in each character)

When I open python and try using swedish characters, it does not output anything at all

When I connect to a Ubuntu server trough SSH I cant type åäö in bash, tough it works in VIM (still trough SSH). And in nano backspace does not work, but if check the box "Delete sends ctrl+H" in the Terminal preferences, backspace starts working in nano but stops working in VIM.

I've tried unchecking all other encodings then UTF-8 in terminal preferences but that does not seem to work either.

I'm sure that every non US-person must have the same issues, so hove do I fix them? I just want full UTF-8 support... :'(

like image 323
Sami Avatar asked Jan 05 '11 16:01

Sami


People also ask

How do I display the UTF-8 terminal?

Go to the language settings, click Administrative language settings, then Change system locale… and tick the Beta: Use Unicode UTF-8 for worldwide language support option. Restart your computer.

What is default encoding on Mac?

Mac OS X uses UTF-8 as its default encoding for representing filenames/paths.

How do I set encoding in terminal?

The terminal can however let applications that interact it know its encoding by setting the locale environment variables. For instance, on macOS you can choose the terminal encoding and optionally set the locale environment variables at terminal startup in Terminal > Preferences > Profiles > Advanced .


2 Answers

For me, this helped: I checked locale on my local shell in terminal

$ locale LANG="cs_CZ.UTF-8" LC_COLLATE="cs_CZ.UTF-8" 

Then connected to any remote host I am using via ssh and edited file /etc/profile as root - at the end I added line:

export LANG=cs_CZ.UTF-8 

After next connection it works fine in bash, ls and nano.

like image 60
angeldust Avatar answered Sep 21 '22 07:09

angeldust


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.

like image 42
ismail Avatar answered Sep 22 '22 07:09

ismail