diff --git a/module/svn/config.php b/module/svn/config.php index 51ba373568..43ed023788 100644 --- a/module/svn/config.php +++ b/module/svn/config.php @@ -1,8 +1,10 @@ svn->repos['pms']['password'] = 'pass'; * */ -$config->svn->client = ''; +$config->svn->encodings = 'utf-8, gbk'; +$config->svn->client = ''; $i = 1; $config->svn->repos[$i]['path'] = ''; diff --git a/module/svn/model.php b/module/svn/model.php index bb23d7b6b3..92fc09bf16 100644 --- a/module/svn/model.php +++ b/module/svn/model.php @@ -320,6 +320,30 @@ class svnModel extends model return array('stories' => $stories, 'tasks' => $tasks, 'bugs' => $bugs); } + /** + * Convert the comment to uft-8. + * + * @param string $comment + * @access public + * @return string + */ + public function iconvComment($comment) + { + /* Get encodings. */ + $encodings = str_replace(' ', '', trim($comment)); + if($encodings == '') return $comment; + $encodings = explode(',', $encodings); + + /* Try convert. */ + foreach($encodings as $encoding) + { + $result = @iconv($encoding, 'utf-8', $comment); + if($result) return $result; + } + + return $comment; + } + /** * Diff a url. * @@ -388,7 +412,7 @@ class svnModel extends model $action->actor = $log->author; $action->action = 'svncommited'; $action->date = $log->date; - $action->comment = $log->msg; + $action->comment = $this->iconvComment($log->msg); $action->extra = $log->revision; $changes = $this->createActionChanges($log, $repoRoot);