From 15beb9f9ef7361329b917f6d2dc5f457addf3626 Mon Sep 17 00:00:00 2001 From: henoheno Date: Mon, 12 Jun 2006 00:01:32 +0900 Subject: [PATCH] Added --decode, --nocheck --- encls.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/encls.php b/encls.php index ebb12ae..2ae76a6 100755 --- a/encls.php +++ b/encls.php @@ -1,7 +1,7 @@ #!/usr/local/bin/php $value) { list($value, $optarg) = explode('=', $value, 2); switch ($value) { case '--all' : $f_all = TRUE; break; + case '--decode' : $f_decode = TRUE; break; + case '--nocheck' : $f_nocheck = TRUE; break; case '--suffix' : $suffix = $optarg; break; case '--encoding_from': $encoding_from = $optarg; break; case '--encoding_to' : $encoding_to = $optarg; break; @@ -118,7 +120,7 @@ if ($f_all && empty($argv)) { $argv = array_keys(get_existpages('.', $suffix)); } else { foreach ($argv as $arg) { - if (! file_exists($arg)) { + if (! $f_nocheck && ! file_exists($arg)) { echo 'File not found: ' . $arg . "\n"; usage(); } @@ -138,10 +140,15 @@ foreach ($argv as $arg) { $suffix = ''; } //echo $name . $suffix . "\n"; // As-is - //echo decode($name) . $suffix . "\n"; // Decorded - echo encode(mb_convert_encoding(decode($name), - TARGET_ENCODING, SOURCE_ENCODING)) . - $suffix . "\n"; // Decord -> convert -> encode + if ($f_decode) { + // Decord + echo decode($name) . $suffix . "\n"; + } else { + // Decord -> convert -> encode + echo encode(mb_convert_encoding(decode($name), + TARGET_ENCODING, SOURCE_ENCODING)) . + $suffix . "\n"; + } //echo "\n"; } ?> -- 2.11.0