From a5f97c59d9e43cb2e544aba340f52c95dad9d78e Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Fri, 26 Mar 2010 14:53:43 +0100 Subject: [PATCH] Fixed missing detection of ISO-8859-2 characters. --- src/IDF/Commit.php | 2 +- src/IDF/Tests/TestGit.php | 18 ++++++++++++++++++ src/IDF/Tests/data/git-log-iso-8859-2.txt | 12 ++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/IDF/Tests/data/git-log-iso-8859-2.txt diff --git a/src/IDF/Commit.php b/src/IDF/Commit.php index c23f712..ba4a1e2 100644 --- a/src/IDF/Commit.php +++ b/src/IDF/Commit.php @@ -171,7 +171,7 @@ class IDF_Commit extends Pluf_Model */ public static function toUTF8($text) { - $enc = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS'; + $enc = 'ASCII, UTF-8, ISO-8859-2, ISO-8859-1, JIS, EUC-JP, SJIS'; $ref = $text; if (is_array($text)) { $ref = $text[0]; diff --git a/src/IDF/Tests/TestGit.php b/src/IDF/Tests/TestGit.php index 9baf254..c7557c1 100644 --- a/src/IDF/Tests/TestGit.php +++ b/src/IDF/Tests/TestGit.php @@ -58,4 +58,22 @@ class IDF_Tests_TestGit extends UnitTestCase } } + + /** + * parse a log encoded in iso 8859-2 + */ + public function testParseIsoLog2() + { + $log_lines = preg_split("/\015\012|\015|\012/", file_get_contents(dirname(__FILE__).'/data/git-log-iso-8859-2.txt')); + $log = IDF_Scm_Git::parseLog($log_lines); + $titles = array( + 'DodaÅ‚em model', + 'DodaÅ‚em model', + ); + foreach ($log as $change) { + $this->assertEqual(array_shift($titles), + IDF_Commit::toUTF8($change->title)); + } + + } } diff --git a/src/IDF/Tests/data/git-log-iso-8859-2.txt b/src/IDF/Tests/data/git-log-iso-8859-2.txt new file mode 100644 index 0000000..e98328c --- /dev/null +++ b/src/IDF/Tests/data/git-log-iso-8859-2.txt @@ -0,0 +1,12 @@ +commit 11531a9dbc64a65150f2f38fbea7cef9d478a123 +Author: unknown +Date: Fri Jul 3 01:44:11 2009 +0200 + + Doda³em model + +commit 11531a9dbc64a65150f2f38fbea7cef9d478a123 +Author: unknown +Date: Fri Jul 3 01:44:11 2009 +0200 + + Doda³em model +