Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am on an Ubuntu (I think) system. I don't have root, so I can't change the locale. I want to make my default terminal profile use UTF-8 by default. There should be a way to do this, either in the .gconf/apps/gnome-terminal/ directory somewhere, or in a environment variable, or something. However, I can't seem to find it.

Edit with more details:

In a terminal, I have:

grid-unv55$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
grid-unv55$ gnome-terminal

When try to more a UTF document in that new terminal, I get:

\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd
\noise:bgspeech \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd

Which appears on my screen as dots. (the uffds were a cut and paste. I left the "\noise:bgspeech" in there so you could see that ascii cut and pasted correctly)

share|improve this question
add comment

4 Answers

up vote 6 down vote accepted

I believe that gnome-terminal will Just Work with UTF-8 is enabled in the shell, so all you need to do is enable that. Put

export LANG=en_US.UTF-8

in ~/.bashrc and there you go.


EDIT:

Okay, so, the answer is currently you can't set this. Gnome Terminal follows the current environment's LANG setting and uses the encoding for that as the default. So you need to get LANG to contain UTF-8 before gnome-terminal is launched. Setting this in ~/.bashrc should do it — you'll just need to log out and log in again.

(Note that it's actually better to put this in ~/.bash_profile so you can override it for subshells, but I'm not sure that bash is necessarily run as a login shell as part of setting up the Gnome environment. That's worth testing....)

share|improve this answer
    
doesn't appear to work. –  Brian Postow Mar 8 '11 at 21:45
    
Hmm. What is $LANG set to by default? Does putting that in your bashrc make it change? –  mattdm Mar 8 '11 at 22:06
    
C, and putting it in the bashrc made it change. Granted, I didn't log-out and log back in again, but I started a new terminal, and it started with UTF in the LANG (and the locale is set with UTF as well) but the terminal still doesn't show Japanese... –  Brian Postow Mar 8 '11 at 22:39
    
What does it show? –  mattdm Mar 8 '11 at 23:12
    
It shows dots. Which, for some reason, cut and paste into firefox as \ufffd –  Brian Postow Mar 9 '11 at 15:50
show 10 more comments

I had a similar problem, and when setting LANG in .bash_profile didn't do the trick, I found out that in Gnome, the default locale can be set at the beginning of a session from the GDM login screen. This can be done without root access.

share|improve this answer
add comment

I just checked in menu->terminal->set character encoding it is utf-8

The terminal and bash are not the same thing.

I would start by doing cat utf-8-file (cat and bash will pass this file unchanged to the terminal, (well actually to stty, stty will convert newline to carrage return, newline etc.)) if this displays the file properly then gnome-terminal is setup. (This so far is all I have ever done, as I use utf-8 in english; it was already set up in Ubuntu 10.10 and Debian 6 for me). So then just to set up bash etc.

Re-reading ~/.bashrc

If you edit ~/.bashrc you must re-read it . ~/.bashrc (or start a new shell) (dont forget the dot)

share|improve this answer
1  
When I manually change the character encoding to utf-8, that's where I do it, but when I start a new gnome-terminal, even from a terminal that has the correct locale, the encoding is still ascii. I'll add more details to the question. –  Brian Postow Mar 9 '11 at 15:45
add comment

I had an issue just now that I fixed that may be relevant for new-comers with newer versions of GNOME (and gnome-terminal):

For any text encoding you want to use, the shell (e.g. bash) and terminal emulator (e.g. gnome-terminal) must use the same encoding. So e.g. if the shell uses en_US.utf8 and the terminal emulator uses en_US.ISO-8859-1 (a.k.a. latin1), then you will see strange text in your terminal for any program with UTF-8 output.

Now, I am not able to set the encoding upon login, as I've seen suggested would be possible. This might be due to the fact that we have an older version of GDM here at work. This is why I've needed a different solution.

Anyway, GNOME 3 doesn't seem to automatically source .bashrc nor .profile upon login. But it does source .gnomerc, in which you can put environment variables that will be exported to GNOME programs (as far as I can tell).

Putting export LANG="en_US.utf8" in .gnomerc thus starts gnome-terminal using a UTF-8 encoding by default, when a new instance is started. (Change your locale according to your needs.)

Hopefully this has been useful to someone!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.