[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Encoding error when calling a ruby script from Emacs using shell-com
From: |
Peter Dyballa |
Subject: |
Re: Encoding error when calling a ruby script from Emacs using shell-command |
Date: |
Sat, 1 Sep 2012 00:40:21 +0200 |
Am 01.09.2012 um 00:18 schrieb Marcelo de Moraes Serpa:
> The problem is that emacs' shell-command doesn't use the same environment,
> so it wasn't picking up the value of those three vars:
>
> ✗ export | grep UTF
> LANG=en_US.UTF-8
> LC_ALL=en_US.UTF-8
> LC_CTYPE=en_US.UTF-8
>
> So, I did this:
>
> (defun test ()
> (setenv "LANG" "en_US.UTF-8")
> (setenv "LC_ALL" "en_US.UTF-8")
> (setenv "LC_CTYPE" "en_US.UTF-8")
> (shell-command "/Users/myself/.rvm/bin/rvm ruby-1.9.3-p194 do
> /usr/bin/rubyscript")
> )
There are more options…
When you want GNU Emacs to run in an en_US.UTF-8 environment you can either use
the three setenv statements in you init file or make the system use this to
launch GNU Emacs:
env LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 emacs … &
If you want to restrict en_US.UTF-8 for the Ruby sub-shell you could also use
without the setenv statements:
(shell-command "env LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
LC_CTYPE=en_US.UTF-8 /Users/myself/.rvm/bin/rvm ruby-1.9.3-p194 do
/usr/bin/rubyscript")
The best option, IMO, is though to set in your login script (~/.profile or
~/.bash_profile) the en_US.UTF-8 environment. Then you'd have this available
everywhere: in shells inside terminal emulations, the X Windows system, and its
clients.
--
Greetings
Pete
One cannot live by television, video games, top ten CDs, and dumb movies alone.
– Amiri Baraka, 1999