Indefero

Indefero Commit Details


Date:2010-03-26 13:57:18 (14 years 8 months ago)
Author:Loic d'Anterroches
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:3c29e4e6ae12a4b3f5a5dee26cea826d6c1cf227
Parents: a5f97c59d9e43cb2e544aba340f52c95dad9d78e
Message:Fixed to not use the assumption that the first line of a commit message set the encoding.

Changes:

File differences

src/IDF/Commit.php
151151
152152
153153
154
154
155
155156
156157
157158
......
167168
168169
169170
170
171
172
171173
172
174
173175
174
176
175177
176178
177179
178180
179181
180
182
181183
182184
183185
......
187189
188190
189191
190
192
191193
192
194
195
193196
194197
195198
$commit = new IDF_Commit();
$commit->project = $project;
$commit->scm_id = $change->commit;
list($commit->summary, $commit->fullmessage) = self::toUTF8(array($change->title, $change->full_message));
$commit->summary = self::toUTF8($change->title);
$commit->fullmessage = self::toUTF8($change->full_message);
$commit->author = $scm->findAuthor($change->author);
$commit->origauthor = $change->author;
$commit->creation_dtime = $change->date;
* first value and then used to convert all the strings.
*
* @param mixed String or array of string to be converted
* @return mixed String or array of string
* @param bool Returns the encoding together with the converted text (false)
* @return mixed String or array of string or array of res + encoding
*/
public static function toUTF8($text)
public static function toUTF8($text, $get_encoding=False)
{
$enc = 'ASCII, UTF-8, ISO-8859-2, ISO-8859-1, JIS, EUC-JP, SJIS';
$enc = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
$ref = $text;
if (is_array($text)) {
$ref = $text[0];
}
if (Pluf_Text_UTF8::check($ref)) {
return $text;
return (!$get_encoding) ? $text : array($text, 'UTF-8');
}
$encoding = mb_detect_encoding($ref, $enc, true);
if ($encoding == false) {
foreach ($text as $t) {
$res[] = mb_convert_encoding($t, 'UTF-8', $encoding);
}
return $res;
return (!$get_encoding) ? $res : array($res, $encoding);
} else {
return mb_convert_encoding($text, 'UTF-8', $encoding);
$res = mb_convert_encoding($text, 'UTF-8', $encoding);
return (!$get_encoding) ? $res : array($res, $encoding);
}
}
src/IDF/Tests/TestGit.php
4848
4949
5050
51
52
53
51
52
53
5454
5555
56
57
56
57
58
59
5860
59
6061
6162
6263
......
6768
6869
6970
70
71
71
72
73
74
75
76
77
78
7279
7380
74
75
81
82
83
84
7685
77
7886
7987
$log_lines = preg_split("/\015\012|\015|\012/", file_get_contents(dirname(__FILE__).'/data/git-log-iso-8859-1.txt'));
$log = IDF_Scm_Git::parseLog($log_lines);
$titles = array(
'Quick Profiler entfernt',
'Anwendungsmenu Divider eingefügt',
'Anwendungen aufäumen'
array('Quick Profiler entfernt', 'UTF-8'),
array('Anwendungsmenu Divider eingefügt', 'ISO-8859-1'),
array('Anwendungen aufäumen', 'ISO-8859-1'),
);
foreach ($log as $change) {
$this->assertEqual(array_shift($titles),
IDF_Commit::toUTF8($change->title));
list($title, $senc) = array_shift($titles);
list($conv, $encoding) = IDF_Commit::toUTF8($change->title, true);
$this->assertEqual($title, $conv);
$this->assertEqual($senc, $encoding);
}
}
/**
$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',
array('Doda³em model','ISO-8859-1'),
array('Doda³em model','ISO-8859-1'),
// The Good result is 'Dodałem model', the
// problem is that in that case, one cannot
// distinguish between latin1 and latin2. We
// will need to add a way for the project
// admin to set the priority between the
// encodings.
);
foreach ($log as $change) {
$this->assertEqual(array_shift($titles),
IDF_Commit::toUTF8($change->title));
list($title, $senc) = array_shift($titles);
list($conv, $encoding) = IDF_Commit::toUTF8($change->title, true);
$this->assertEqual($title, $conv);
$this->assertEqual($senc, $encoding);
}
}
}

Archive Download the corresponding diff file

Page rendered in 0.07503s using 13 queries.