2008-01-07
■[Subversion][Linux]WebSVNの文字化け対策
WebSVNの文字化け対策は検索すれば結構出てくるけど、対象とするWebSVNのバージョンが古いのか辻褄の合わないところがあったので改めてメモ。
WebSVNは2.0で、そのほかの環境はこんな感じ。
# echo $LANG ja_JP.UTF-8 # httpd -v Server version: Apache/2.2.6 (Unix) Server built: Sep 18 2007 03:54:41 # svn --version --quiet 1.4.4
コミットログの文字化け
コミットログは何もしなくても文字化けしなかった
ファイル名の文字化け
include/config.phpのどこかに追記。
putenv('LANG=ja_JP.UTF-8');
ソースの文字化け
include/config.phpの「LANGUAGE SETUP ---」のところで、次のようにエンコーディングを設定する。
$config->setInputEncoding('UTF-8'); $config->setContentEncoding('UTF-8');
include/svnlook.phpを書き換えて「/usr/bin/nkf -w」を追加していく。
SVNRepository::getFileContents内:
if ($l == "php")
{
// Output the file to the filename
$path = encodepath($this->repConfig->path.$path);
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path)."@$rev"." | /usr/bin/nkf -w"." > $filename"); // " | /usr/bin/nkf -w" を追加
...
}
else
{
if ($config->useEnscript)
{
// Get the files, feed it through enscript, then remove the enscript headers using sed
//
// Note that the sec command returns only the part of the file between <PRE> and </PRE>.
// It's complicated because it's designed not to return those lines themselves.
$path = encodepath($this->repConfig->path.$path);
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path)."@$rev"." | ".
"/usr/bin/nkf -w | ". // 追加
$config->enscript." --language=html ".
($l ? "--color --pretty-print=$l" : "")." -o - | ".
$config->sed." -n ".$config->quote."1,/^<PRE.$/!{/^<\\/PRE.$/,/^<PRE.$/!p;}".$config->quote." > $filename");
SVNRepository::listFileContents内:
if ($l == "php")
{
$tmp = tempnam("temp", "wsvn");
// Output the file to a temporary file
$path = encodepath($this->repConfig->path.$path);
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path)."@$rev"." | /usr/bin/nkf -w"." > $tmp"); // " | /usr/bin/nkf -w" を追加
...
}
else
{
if ($config->useEnscript)
{
$path = encodepath($this->repConfig->path.$path);
$cmd = quoteCommand($config->svn." cat ".$this->repConfig->svnParams().quote($path)."@$rev"." | ".
"/usr/bin/nkf -w | ". // 追加
$config->enscript." --language=html ".
($l ? "--color --pretty-print=$l" : "")." -o - | ".
$config->sed." -n ".$config->quote."/^<PRE.$/,/^<\\/PRE.$/p".$config->quote);
とりあえずこれで文字化けしなくなった。
トラックバック - http://d.hatena.ne.jp/okonomi/20080107/1199699621
リンク元
- 2 http://b.hatena.ne.jp/entry/5920259
- 2 http://d.hatena.ne.jp/keyword/マジコン
- 2 http://d.hatena.ne.jp/keyword/NDS
- 2 http://r.hatena.ne.jp/r-ymsk/
- 2 http://www.google.co.jp/search?q=fedora7+ネットワークインストール&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&client=firefox-a
- 2 http://www.study02.net/2007/08/colinux_071_fedoracore7.html
- 1 http://72.14.235.104/search?q=cache:IV9G5xGFljEJ:d.hatena.ne.jp/okonomi/20070825/1188063517+fedora7+GV-MVP&hl=ja&ct=clnk&cd=1&gl=jp
- 1 http://d.hatena.ne.jp/iww/20080110/1199953479
- 1 http://d.hatena.ne.jp/keyworddiary/NDS
- 1 http://d.hatena.ne.jp/keyworddiary/Subversion
