]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Minor, don't explode when mbstring is missing and don't do utf8-to-utf8 conversions.
authorepriestley <git@epriestley.com>
Tue, 3 Jul 2012 02:34:59 +0000 (19:34 -0700)
committerepriestley <git@epriestley.com>
Tue, 3 Jul 2012 02:34:59 +0000 (19:34 -0700)
src/workflow/ArcanistDiffWorkflow.php

index cea9f0996bf1768de3cb75f8b9ac69a8bf9aa310..4fe85c99472533e4d6ab8494e16f6490dc411ccd 100644 (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;
               }