Several times I required to enable Japanese in my Linux or in my web pages. This is a quick reference of how to setup your Linux or Web pages in order to display or use Japanese correctly.
Japanese in Ubuntu
Since I'm currently using Ubuntu, I will show first how to enable it in Ubuntu. When I was using Slackware the process was quite different, you may wish to look at the links I added at the end of this page.
How to enable Japanese IME in Ubuntu Linux:
1. sudo apt-get install uim anthy scim-gtk2-immodule scim-uim
2. in /etc/X11/Xsession.d/
create: 78japanese_ime:
export XMODIFIERS="@im=SCIM"
export GTK_IM_MODULE="scim"
export XIM_PROGRAM="scim -d"
export QT_IM_MODULE="scim"
3. sudo dpkg-reconfigure locales
4. It is recommendable to install additional Japanese fonts.
UPDATE: I tried my method in KDE but it didn't work, so I found out that you may require to install one more package:
sudo apt-get install scim-bridge
Then, edit the file /etc/X11/xinit/xinput.d/scim and replace the value of "GTK_IM_MODULE" and "QT_IM_MODULE" from "xim" to "scim-bridge".
Your file may look like this:
XIM=SCIM
XIM_PROGRAM=/usr/bin/scim
XIM_ARGS="-d"
XIM_PROGRAM_SETS_ITSELF_AS_DAEMON=yes
GTK_IM_MODULE="scim-bridge"
QT_IM_MODULE="scim-bridge"
DEPENDS="scim,scim-anthy|scim-canna|scim-chewing|scim-pinyin|scim-hangle|scim-prime|scim-skk|scim-tables-additional|scim-m17n|scim-u
im|scim-tables-ja|scim-tables-ko|scim-tables-zh"
Japanese in Php:
How to enable Japanese in Php (this may change in PHP6):
1. Compile your php with the --enable-mbstring argument, or add the respective module.
2. In your php.ini:
[mbstring]
mbstring.language = Japanese
; you may want to change this encoding according to your preference
mbstring.internal_encoding = UTF-8
; this is important to be able to manipulate coding in forms.
mbstring.http_input = pass
; also you can modify this encoding to EUC-JP / Shift_JIS / ISO-2022-JP / UTF-16
mbstring.http_output = UTF-8
mbstring.detect_order = auto
mbstring.substitute_character = none;
3. In the top your php file:
define (CHARSET,"EUC-JP");
header("Content-Type: text/html; charset=".CHARSET);
additionally, it is recommendable to add it to your meta tags:
This CHARSET, means the encoding of your data. For example if you store as EUC-JP your data in your database, in order to show it correctly (without any transformation) to that value.
Sometimes will be desire to receive in your forms with certain encoding, to do so, add at you