<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE artikkel PUBLIC "-//infoweb.ntnu.no//DTD Infoweb 1.0//NO"
          "http://infoweb.ntnu.no/infoweb.dtd">

<artikkel spraak="en">
  <tittel>Using UTF-8 in UNIX-terminals and programs</tittel>
  <forfatter>livermor</forfatter>
  <sammendrag>Hot to configure terminalemulators such as PuTTY, uxterm, Gnome Terminal and a UNIX-environment to use UTF-8.</sammendrag>
  <hoveddel>
  <!--
<avsnitt>
Dersom du har lest artikkelen om <infoweb aid="477" tittel="Unicode og tegnsett generelt">Unicode og tegnsett generelt</infoweb>, kan du konfigurere Unix-terminalene dine og andre programmer til å bruke UTF-8.
</avsnitt>
-->
<avsnitt>
If you want to use UTF-8 in your terminal emulator, it has to support UTF-8 and a system with UTF-8-locales installed. Locales are definitions for date, language, timezone settings, currency and most user defined parameters. Most GNU/Linux-distributions have UTF-8-locales installed.
</avsnitt>
<avsnitt>
When logging onto servers like login.stud.ntnu.no with UTF-8 you have to configure your terminalemulator first. In PuTTY you have to go to the <uthev>Translation</uthev> under the <uthev>Category</uthev>-part and choose UTF-8 in the list <kursiv>Character sets translation on received data</kursiv>. <kursiv>uxterm</kursiv> and <kursiv>urxvt</kursiv> use UTF-8 as default, and in <kursiv>Gnome Terminal</kursiv> you might have to change the settings in the menu <uthev>Terminal</uthev>-<uthev>Choose character set</uthev>-<uthev>UTF-8</uthev>.</avsnitt>
<avsnitt>
You have to tell the system you want to use UTF-8-locales after you've logged in. You can check to see what locale you're using with <kommando>locale</kommando></avsnitt>
<konsoll>
gaupe:~$ locale
LANG=en_US
LC_CTYPE=nb_NO
LC_NUMERIC=nb_NO
LC_TIME=nb_NO
LC_COLLATE="en_US"
LC_MONETARY="en_US"
LC_MESSAGES="en_US"
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=
</konsoll>
<avsnitt>
To change the locales, you use the command <kommando>export</kommando>. You will want to change <kursiv>LANG</kursiv> and <kursiv>LC_ALL</kursiv> on gaupe like this:
<konsoll>
gaupe:~$ export LANG=en_DK.UTF-8
gaupe:~$ export LC_ALL=en_DK.UTF-8
gaupe:~$ locale
LANG=en_DK.UTF-8
LC_CTYPE="en_DK.UTF-8"
LC_NUMERIC="en_DK.UTF-8"
LC_TIME="en_DK.UTF-8"
LC_COLLATE="en_DK.UTF-8"
LC_MONETARY="en_DK.UTF-8"
LC_MESSAGES="en_DK.UTF-8"
LC_PAPER="en_DK.UTF-8"
LC_NAME="en_DK.UTF-8"
LC_ADDRESS="en_DK.UTF-8"
LC_TELEPHONE="en_DK.UTF-8"
LC_MEASUREMENT="en_DK.UTF-8"
LC_IDENTIFICATION="en_DK.UTF-8"
LC_ALL=en_DK.UTF-8
</konsoll>
You might have to put the <kommando>export</kommando>-commands in <kursiv>.bashrc</kursiv>. That way you will not have to write them each time you log on. It looks a bit weird that you want to have English like they speak it in Denmark... But this just means that you want English language with nordic timezone, currency and other things that are area-specific. If you want your programs in Norwegians instead of in English, use <kursiv>nb_NO.UTF-8</kursiv>.
</avsnitt>

<os2>vim and UTF-8</os2>
<avsnitt>
vim uses UTF-8 internally, and converts between character sets when reading and writing files. You can instruct vim to use UTF-8 by default (unless it detects otherwise) by putting the following in your .vimrc:
<kode>
set fileencoding=utf-8
set encoding=utf-8
set termencoding=utf-8
</kode>
</avsnitt>

<os2>UTF-8 and emacs</os2>
<avsnitt>
Emacs on login.stud.ntnu.no supports UFT-8. If your version doesn't, you probably have to install mule (<kommando>sudo aptitude install mule-ucs</kommando>) and add the following to your .emacs (or .xemacs/custom.el):</avsnitt>
<kode>
(prefer-coding-system 'mule-utf-8)
(setq locale-coding-system 'mule-utf-8)
(set-terminal-coding-system 'mule-utf-8)
(set-keyboard-coding-system 'mule-utf-8)
(set-selection-coding-system 'mule-utf-8)
</kode>


<os2>Using UTF-8 with irssi</os2>
<avsnitt>
If you want to use UTF-8 with <kursiv>irssi</kursiv>, you type the following into your terminal: 
<kode>/set term_charset UTF-8</kode>

Newer versions of irssi allow customizing the character sets of different channels with the command <kommando>recode</kommando>:

<kode>/set recode_out_default_charset UTF-8</kode>
Then, for each channel you want UTF-8 in:
<kode>/recode add UTF-8</kode>
For further explanation, see <kode> /help recode </kode>.

</avsnitt>

<os2>mutt and UTF-8</os2>
<avsnitt>
If you use mutt for e-mail, you can configure the <kursiv>.muttrc</kursiv>-file to use UTF-8:
<kode>
set charset=utf-8
set send_charset=utf-8
</kode>
You also have to make sure your editor for mutt uses UTF-8. So for vim that means you have to add the following lines to <kursiv>.vimrc</kursiv>:
<kode>
au BufNewFile,BufRead mutt*    set tw=77 ai nocindent fileencoding=utf-8
</kode>
</avsnitt>

<os2>UTF-8 and pine</os2>
<avsnitt>
The e-mail client pine does not support UTF-8.
</avsnitt>
<avsnitt>
It is possible, if you really want to, to use UTF-8 in pine. You have to use a program that translates everything going in and out so that pine still thinks its UTF-8-less:
<kode>
user@gaupe:~$ luit -encoding 'ISO-8859-1' pine
</kode>
Unfortunately, this is not an optimal solution and it is preferable to use an e-mail client that really supports UTF-8.

</avsnitt>



  </hoveddel>
</artikkel>
