Tuesday, December 21, 2010

How to handle Chinese file name correctly in Mldonkey

  1. I have Mandriva and locale of Mldonkey isn't printed in log file. Therefore I checked the command that starts mldonkey service (default is /etc/init.d/mldonkey). I saw the following
    daemon --user mldonkey --check mlnet $NICE $mldonkey $params >/dev/null 2>&1 &
    and I changed it to
    daemon --user mldonkey --check mlnet $NICE $mldonkey $params >/dev/null 2>$LOGFILE &

  2. After I restart Mldonkey servcie, I check the log file again(default is /var/log/mldonkey.log). I saw the following
    [cO] Language en_US, locale ISO88591, ulimit for open files 1024
  3. The function daemon is defined in /etc/init.d/functions and the following is invoked
    su -s /bin/bash - $user -c "$corelimit > /dev/null 2>&1 ; $*"
    which means mldonkey service is started in a login bash shell of user mldonkey and the file .bash_profile in its home directory should have the correct environment variables set.
  4. I added the following line to the file /var/lib/mldonkey/.bash_profile (or ~/.i18n)
    export LC_ALL=zh_CN.GBK
    I didn't set the above to zh_CN.utf8 since my samba also had the line unix charset = GBK in smb.conf
  5. After restarting the mldonkey service, the following is shown in the log file and Chinese file names are handled correctly (instead of using underscores everywhere)
    [cO] Language ZH_CN, locale GBK, ulimit for open files 1024

No comments: