2024年4月19日(金) 11:02 JST

Geeklog の文字化け対策

  • 2006年4月 6日(木) 13:59 JST
  • 投稿者:
  • 表示回数 5,959
Geeklog //=================================================//
// 表示用には COM_truncate($text, length, '...') を,データベースへの保存用    //
// には mb_strcut($text, 0, length) を使うのが基本。EUC-JPの場合は全角文字は  //
// 2バイトなので,COM_truncate() を使ってもうまくいくが,UTF-8の場合は全角文    //
// 字は 3バイトなので,失敗する。                                  //
//=================================================//

・ファイル管理(FileMgmtプラグイン)

private/plugins/filemgmt/fuction.inc の733行目を

$str .= stripslashes(substr($title,0,$filemgmtWhatsNewTitleLength));

から

$str .= COM_truncate(stripslashes($title),$filemgmtWhatsNewTitleLength.'...');

に変更。

同じく 757 行目を

$str .= stripslashes(substr($title,0,$titleLength));

から

$str .= COM_truncate(stripslashes($title),$titleLength,'...');

に変更。
-------------------------------------------------------------------------------

・RSS フィード
lib-syndication.php の 713行目を

$text = substr( $text, 0, $length - 3 ) . '...';

から

$text = COM_truncate( $text, $length, '...');

に変更。
-------------------------------------------------------------------------------

・新着情報
lib-common.php の 4131行目を

$titletouse = substr( $titletouse, 0, 17 ) . '...';

から

$titletouse = COM_truncate( $titletouse, 20, '...');

に変更。
-------------------------------------------------------------------------------

・記事中のリンクを AutoTag で抜き出すときのリンクテキスト
lib-story.php の 490行目を

$matches[2][$i] = substr( $matches[2][$i], 0, $maxlength - 3 ) . '...';

から

$matches[2][$i] = COM_truncate( $matches[2][$i], $maxlength, '...');

に変更。
-------------------------------------------------------------------------------

・記事のタイトル

/admin/story.php の DB_save の前に

$title = mb_strcut($title, 0, 128); // COM_truncate()ではダメ

を追加。