Table of contents:
Slackware and UTF-8As i try to convert my systems to UTF-8 i'm taking a few notes. Hopefully that should be useful to others. I'm not going to go into details their is alredy a lot of nice sources on the net.
Basic setup
Setting LANGFor a real global setting simply put LANG=en_US.utf8 in your boot parameters, that way everything use the right local straight from boot. Otherwise one can use /etc/environement to just set it for the user sessions. However some claims it doesn't work with bash.
Setting the linux console3 things must be done: enable UTF-8 processing, load a unicode font and set the keymap to produce UTF-8 chars. Enabeling UTF-8 processing is simple, just echo ESC % G. This should preferably be done early in the boot process to make sure the console doesn't bug (even if special chars can't be displayed yet). Add the following at the start of /etc/rc.d/rc.S:
if echo "$LANG" | grep -q -i utf8 ; then
# Tell the console we output multibyte chars
echo "Enable multibyte console"
echo -n -e '\033%G'
fi
For the font just choose one with the psfu or psfu.gz extension (they are in /usr/share/kbd/consolefonts) and set it in /etc/rc.d/rc.font. For the keymap edit /etc/rc.d/rc.keymap and add this at the end:
# Turn tke keymap in unicode
if echo "$LANG" | grep -q -i utf8 ; then
# Enable multibyte input
kbd_mode -u
# Load the keymap in unicode mode
/usr/bin/dumpkeys | /usr/bin/loadkeys --unicode
fi
Finally edit /etc/profile.d/lang.sh, comment the LANG setting and add the following at the end:
# Set UTF-8 related stuff
if echo "$LANG" | grep -q -i utf8 ; then
# Ensure the console handle UTF-8 if needed.
[ "$TERM" = "linux" ] && echo -n -e '\033%G'
export LESSCHARSET=utf-8
fi
Applications
lessSet LESSCHARSET=utf-8 in profile.
manEdit /usr/lib/man.conf and change NROFF to:
NROFF /usr/bin/nroff -Tutf8 -mandoc
jedUpdate to a version using slang2, jed-0.99_18 work fine.
apache (1.x)The directory listing produced by apache doesn't have any charset specified and there is no way to configure it. However a custom HTML page header can be set from a static HTML page or a CGI. To enable it, in the mod_autoindex section of /etc/apache/httpd.conf set HeaderName and SuppressHTMLPreamble:
<IfModule mod_autoindex.c>
...
HeaderName /cgi-bin/dirhdr.html
IndexOptions NameWidth=* TrackModified SuppressHTMLPreamble
</IfModule>
A simple HTML page would do it but having the path of the directory as title is better and to do that a CGI is needed. The script is named in .html because apache need the header file to be of text type (yes the script itself, not its output). While at it some css can be added to make it look nicer.
#!/bin/sh
echo "Content-Type: text/plain; charset=UTF-8"
echo
dir="${REQUEST_URI%/*}"
cat <<EOF
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- Dir listing header with the right charset -->
<HTML>
<HEAD>
<TITLE>Index of $dir</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<LINK rel="stylesheet" type="text/css" href="/dirhdr.css"/>
</HEAD>
<BODY>
<H1>Index of $dir</H1>
EOF
PHPmbstring.internal_encoding default to ISO-8859-1. In /etc/apache/php.ini set it to UTF-8.
|