Monday, September 19, 2011

UTF8 in OSX terminal

After 3.5 years of using MacBook Pro I could not stand ???? symbols in OSX terminal anymore. Funny thing, the trigger was an example of Union types for Scala, which used some mathematical symbols in the identifier names. So I looked for a solution, and it was so easy, I could not believe I did not do this earlier.

  1. Open /Developer/Applications/Utilities/Property List Editor. I suppose, it was installed together with developer tools from the OSX installation disk.
  2. Select File | Open in menu and open or create file environment.plist in .MacOSX directory in your home dir.
  3. Add key LANG with type String and value en_US.UTF-8
  4. Add key JAVA_OPTS with value -Dfile.encoding=UTF-8
  5. Save everything, log out and back into your account.

After doing that, I was able to use UTF-8 in Terminal. So easy!

P.S. Many kudos to for autosaving the draft of this post. When I logged out to check this solution, I was sure the text I entered was lost. But when I opened Chrome, all the text I entered was still here. Nice!

No comments: