From d3313e3fd78b4708f92aea6b9aa140f2a64c2936 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 2 Jul 2012 19:34:59 -0700 Subject: [PATCH] Minor, don't explode when mbstring is missing and don't do utf8-to-utf8 conversions. --- src/workflow/ArcanistDiffWorkflow.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php index cea9f099..4fe85c99 100644 --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -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; }