1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 14:52:40 +01:00

Minor, don't explode when mbstring is missing and don't do utf8-to-utf8 conversions.

This commit is contained in:
epriestley 2012-07-02 19:34:59 -07:00
parent 563230b0fb
commit d3313e3fd7

View file

@ -835,15 +835,19 @@ EOTEXT
}
}
if ($try_encoding) {
// NOTE: This feature is HIGHLY EXPERIMENTAL and will cause a lot
// of issues. Use it at your own risk.
if ($try_encoding && $try_encoding != 'UTF-8') {
if (!function_exists('mb_convert_encoding')) {
throw new ArcanistUsageException(
"This diff includes a file encoded in '{$try_encoding}', ".
"but you don't have the PHP mbstring extension installed ".
"so it can't be converted to UTF-8. Install mbstring.");
}
$corpus = mb_convert_encoding($corpus, 'UTF-8', $try_encoding);
$name = $change->getCurrentPath();
if (phutil_is_utf8($corpus)) {
$this->writeStatusMessage(
"[Experimental] Converted a '{$name}' hunk from ".
"'{$try_encoding}' to UTF-8.\n");
"Converted a '{$name}' hunk from '{$try_encoding}' ".
"to UTF-8.\n");
$hunk->setCorpus($corpus);
continue;
}