Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit c8d41f0

Browse files
author
Michael Grauer
committed
BUG: refs #0422. Usability enhancements to Utf8tools.php .
1 parent 7a3efe0 commit c8d41f0

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tests/Utf8tools.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,14 @@ function getMatchingFilesRecursive($src, $dir = '')
9292
}
9393

9494
/**
95-
* create a listing of files from the MIDAS BASE DIR (..), checks
95+
* create a listing of files, should be called from the MIDAS BASE DIR, checks
9696
* them for non-utf8 encoded files, and if createUtf8Version is true,
9797
* will create another file in the same dir alongside any non-utf8 file
9898
* that is utf8 encoded and has the same name as the non-utf8 file, with
9999
* an extension of .utf8 .
100100
*/
101101
public function listNonUtf8Files($createUtf8Version = false)
102102
{
103-
// change to MIDAS BASE DIR
104-
chdir("..");
105103
$allFiles = $this->getMatchingFilesRecursive('.');
106104
echo "The following files have non UTF-8 characters:\n\n";
107105
foreach($allFiles as $file)
@@ -124,8 +122,20 @@ public function listNonUtf8Files($createUtf8Version = false)
124122

125123
}
126124

127-
125+
// don't create utf8 versions by default
126+
$create = false;
127+
if(sizeof($argv) > 1)
128+
{
129+
if($argv[1] !== 'create')
130+
{
131+
echo "Usage (should be from MIDAS BASE DIR):\n\nphp Utf8tools.php [create]\n\noptional argument create says to create utf8 versions on non utf8 encoded files\n";
132+
exit();
133+
}
134+
else
135+
{
136+
$create = true;
137+
}
138+
}
128139
$utf8 = new Utf8tools();
129-
// create utf8 versions
130-
$utf8->listNonUtf8Files(true);
140+
$utf8->listNonUtf8Files($create);
131141
?>

0 commit comments

Comments
 (0)