Annotation of wikisrc/tutorials/unicode.mdwn, revision 1.4

1.1       sevan       1: How to use wide-range characters a.k.a. UTF-8 in NetBSD. 
                      2: 
                      3: **Contents**
                      4: 
                      5: [[!toc levels=3]]
                      6: 
                      7: #  Introduction 
                      8: 
                      9: This is all about Unicode on NetBSD. 
                     10: 
                     11: #  Note on wscons 
                     12: 
                     13: wscons doesn't support UTF-8, you'll need **X11** and a proper **X terminal emulator** for this to be of any use, or you get character mash for lunch! Only the [ASCII](http://de.wikipedia.org/wiki/ASCII-Tabelle) part of Unicode, namely the **first 128 characters, will work** in your wscons console, as they overlap in both UTF-8 and ISO-8859 character sets: 
                     14:     
                     15:      !"#$%&'()*+,-./0123456789:;<=>?     
                     16:          @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ 
                     17:          `abcdefghijklmnopqrstuvwxyz{|}~  
                     18:     
                     19: 
                     20: #  pkgsrc 
                     21: 
                     22: To make packages that support it use the ncurses library with wide-characters, add to `/etc/mk.conf`
                     23:     
                     24:       PKG_DEFAULT_OPTIONS+= ncursesw
                     25:     
                     26: 
                     27: #  Soup up a shell 
                     28: 
                     29: ##  ksh 
                     30: 
                     31: Works. 
                     32:     
                     33:       chsh -s /bin/ksh
                     34:     
                     35: 
                     36: ##  mksh 
                     37: 
                     38: This one is an OpenBSD based Korn shell, works pretty well compared to the pdksh. 
                     39:     
                     40:        cd /usr/pkgsrc/shells/mksh
                     41:        make install clean
                     42:        chsh -s /usr/pkg/bin/mksh
                     43:     
                     44: 
                     45: ##  zsh 
                     46: 
                     47: UTF-8 in the Z shell is enabled by default since 4.3.2. 
                     48:     
                     49:        cd /usr/pkgsrc/shells/zsh
                     50:        make install clean
                     51:        chsh -s /usr/pkg/bin/zsh
                     52:     
                     53: 
                     54: ##  tcsh 
                     55: 
                     56: Works out of the box. 
                     57:     
                     58:        cd /usr/pkgsrc/shells/tcsh
                     59:        make install clean
                     60:        chsh -s /usr/pkg/bin/tcsh
                     61:     
                     62: 
                     63: ##  bash 
                     64: 
                     65: Works out of the box. 
                     66:     
                     67:        cd /usr/pkgsrc/shells/bash
                     68:        make install clean
                     69:        chsh -s /usr/pkg/bin/bash
                     70:     
                     71: 
                     72: ##  Shell environment 
                     73: 
1.4     ! leot       74: Set the variables `LANG` in your shell configuration file :
1.1       sevan      75:     
                     76:        export LANG="en_US.UTF-8"
                     77: 
                     78: or if you have a C-style shell 
                     79:     
                     80:        setenv LANG "en_US.UTF-8"
                     81: 
                     82: The result should look like 
                     83:     
                     84:        % locale
                     85:        LANG="en_US.UTF-8"
                     86:        LC_CTYPE="en_US.UTF-8"
                     87:        LC_COLLATE="C"
1.4     ! leot       88:        LC_TIME="en_US.UTF-8"
        !            89:        LC_NUMERIC="en_US.UTF-8"
        !            90:        LC_MONETARY="en_US.UTF-8"
1.1       sevan      91:        LC_MESSAGES="en_US.UTF-8"
                     92:        LC_ALL=""
                     93:     
                     94: 
                     95: #  X Terminal emulators 
                     96: 
                     97: ##  xterm 
                     98: 
                     99:   * Versions 239 and over work well with default "fixed" font 
                    100:   * Also works with ttf DejaVu Mono font 
                    101:   * Appears to have trouble with some other fonts such as Bitstream Vera Sans Mono despite this font being more complete than DejaVu 
                    102: 
                    103: ##  gnome-terminal 
                    104: 
                    105:   * Awesome and works great with the ttf Bitstream Vera Sans Mono or DejaVu Mono. 
                    106:   * Somewhat bloated considering the dependencies. 
                    107: 
                    108: ##  urxvt 
                    109: 
                    110: recommended 
                    111:     
                    112:        cd /usr/pkgsrc/x11/rxvt-unicode
                    113:        make install clean
                    114:     
                    115: 
                    116: ##  uxterm 
                    117: 
                    118:   * Works, as the 'u' might suggest, but last time I checked it sucked. Anyone? 
                    119: 
                    120: ##  aterm 
                    121: 
                    122:   * Doesn't work and probably never will. 
                    123: 
                    124: ##  Eterm 
                    125: 
                    126:   * Doesn't work either. Last time I checked the author was too busy with real-life. 
                    127: 
                    128: #  Utilities 
                    129: 
                    130: ##  less 
                    131: 
                    132:   * Set the shell environment variable `LESSCHARSET` to "`utf-8`". 
                    133: 
                    134: ##  screen 
                    135: 
                    136: `.screenrc` 
                    137:     
                    138:        defutf8 on
                    139:        encoding UTF-8
                    140:     
                    141: 
                    142: ##  lynx 
                    143: 
                    144: `.lynxrc`
                    145:     
                    146:        character_set=UNICODE (UTF-8)
                    147:     
                    148: 
                    149: Or change "Display character set" in the options menu. 
                    150: 
                    151: ##  irssi 
                    152:     
                    153:        /set recode_autodetect_utf8 yes
                    154:        /set recode_fallback iso-8859-1  (or whatever seems fit)
                    155:        /set recode_out_default_charset UTF-8          
                    156:        /set term_charset UTF-8           
                    157:        /save        
                    158:     
                    159: 
                    160: ##  silc-client 
                    161:     
                    162:        /set term_type utf-8
                    163:        /save
                    164:     
                    165: 
                    166: and restart. 
                    167: 
                    168: ##  vi 
                    169: 
                    170:   * NetBSD's vi is based on nvi. It doesn't support wide-range characters as of version 1.79nb16 from 10/23/96, which is the one in current 4.99.15 and all releases thereunder. 
                    171: 
                    172: ##  nvi 
                    173: 
1.3       leot      174: pkgsrc' nvi (v1.81.6) works with wide-range characters if built with `wide-curses` option,
                    175: e.g. by adding to mk.conf:
                    176: 
                    177:       PKG_OPTIONS.nvi+= wide-curses
1.1       sevan     178: 
                    179: ##  vim 
                    180: 
                    181: `.vimrc`
                    182:     
                    183:        set encoding=utf-8           
                    184:        set fileencoding=utf-8
                    185:     
                    186: 
                    187: ##  emacs 
                    188: 
                    189: `.emacs`
                    190:     
                    191:        ; === Set character encoding ===
                    192:        (setq locale-coding-system 'utf-8)
                    193:        (set-terminal-coding-system 'utf-8)
                    194:        (set-keyboard-coding-system 'utf-8)
                    195:        (set-selection-coding-system 'utf-8)
                    196:        (prefer-coding-system 'utf-8)
                    197:     
                    198: 
                    199: This one gives you umlauts: 
                    200:     
                    201:        ; === Make ä, ö, ü, ß work ===
                    202:        (set-language-environment 'german)
                    203:     
                    204: 
                    205: ##  mutt 
                    206: 
                    207: mutt should work with all the above. If it doesn't, put in your .muttrc something like 
                    208:     
                    209:       set charset="utf-8:iso-8859-1"
                    210:     
                    211: 
                    212: If you haven't set it in PKG_DEFAULT_OPTIONS already, you may also add to mk.conf 
                    213:     
                    214:       PKG_OPTIONS.mutt+= ncursesw
                    215:     
                    216: 
                    217: #  Servers 
                    218: 
                    219: ##  Apache2 
                    220: 
                    221: `/usr/pkg/etc/httpd/httpd.conf`
                    222:     
                    223:       AddDefaultCharset UTF-8
                    224:     
                    225: 
                    226: #  Converting files 
                    227: 
                    228: If you have files containing non-ASCII ISO-8859 characters your system now will assume these are UTF-8 characters. They're not though, and the characters in these files will be misinterpreted which means that tools that use them will start breaking. Use iconv to convert these, which is part of the base system. 
                    229:     
                    230:        iconv -f iso8859-1 -t utf-8 file >file.new
                    231:     
                    232: 
                    233: #  Filesystems 
                    234: 
                    235:   * Be careful with special characters in filenames, as they'll look weird when you try to access them from a non-unicode environment. 
                    236: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb