2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Roundcubeの文字化け対策

Last updated at Posted at 2016-02-19

Roundcubeが文字化ける

仕事でWebメーラーとして、Roundcubeを使うこととなりました。
しかし、Roundcubeはデフォルトだと、機種依存文字が表示されません。
機種依存文字使うんじゃねーよというところもありますが、
そんなのあんまり気にせず表示したい……
なので、対応してみました。

使用しているバージョン

Roundcube v1.0.5
(バージョンによって、コードが移動したりすることがある模様)

ファイルのダウンロード

mime.types


http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types

上記のファイルを"roundcube/config/"に保存する

ファイルの修正

roundcube/program/lib/Roundcube/rcube_charset.php


// convert charset using mbstring module
if ($mbstring_list !== false) {
    $aliases['WINDOWS-1257'] = 'ISO-8859-13';
    // it happens that mbstring supports ASCII but not US-ASCII
    if (($from == 'US-ASCII' || $to == 'US-ASCII') && !in_array('US-ASCII', $mbstring_list)) {
        $aliases['US-ASCII'] = 'ASCII';
    }


// convert charset using mbstring module
if ($mbstring_list !== false) {
    $aliases['WINDOWS-1257'] = 'ISO-8859-13';
    // Customize from here
    $aliases['JIS'] = 'ISO-2022-JP-MS';
    $aliases['ISO-2022-JP'] = 'ISO-2022-JP-MS';
    $aliases['EUC-JP'] = 'EUCJP-WIN';
    $aliases['SJIS'] = 'SJIS-WIN';
    $aliases['SHIFT_JIS'] = 'SJIS-WIN';
    // Customize to here

    // it happens that mbstring supports ASCII but not US-ASCII
    if (($from == 'US-ASCII' || $to == 'US-ASCII') && !in_array('US-ASCII', $mbstring_list)) {
        $aliases['US-ASCII'] = 'ASCII';
    }

rcube_charset.phpでは加えて、
mbstring関連の処理コードをiconv関連コードより上に移動させておきます。
そうするとmbstringが優先的に使用されるようになるそうです。重要!

roundcube/config/defaults.inc.php


// Absolute path to a local mime.types mapping table file.
// This is used to derive mime-types from the filename extension or vice versa.
// Such a file is usually part of the apache webserver. If you don't find a file named mime.types on your system,
// download it from http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
$config['mime_types'] = null;


// Absolute path to a local mime.types mapping table file.
// This is used to derive mime-types from the filename extension or vice versa.
// Such a file is usually part of the apache webserver. If you don't find a file named mime.types on your system,
// download it from http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
$config['mime_types'] = '/virtual/htdocs/ikou_ssl/roundcube/config/mime.types';

以上で、文字化け対策できたはず。

参考サイト

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?