Revision | 15beb9f9ef7361329b917f6d2dc5f457addf3626 (tree) |
---|---|
Time | 2006-06-12 00:01:32 |
Author | henoheno <henoheno> |
Commiter | henoheno |
Added --decode, --nocheck
@@ -1,7 +1,7 @@ | ||
1 | 1 | #!/usr/local/bin/php |
2 | 2 | <?php |
3 | 3 | // PukiWiki - Yet another WikiWikiWeb clone. |
4 | -// $Id: encls.php,v 1.2 2006/05/14 15:05:19 henoheno Exp $ | |
4 | +// $Id: encls.php,v 1.3 2006/06/11 15:01:32 henoheno Exp $ | |
5 | 5 | // Copyright (C) 2006 PukiWiki Developers Team |
6 | 6 | // License: GPL v2 or (at your option) any later version |
7 | 7 | // |
@@ -103,6 +103,8 @@ foreach ($argv as $key => $value) { | ||
103 | 103 | list($value, $optarg) = explode('=', $value, 2); |
104 | 104 | switch ($value) { |
105 | 105 | case '--all' : $f_all = TRUE; break; |
106 | + case '--decode' : $f_decode = TRUE; break; | |
107 | + case '--nocheck' : $f_nocheck = TRUE; break; | |
106 | 108 | case '--suffix' : $suffix = $optarg; break; |
107 | 109 | case '--encoding_from': $encoding_from = $optarg; break; |
108 | 110 | case '--encoding_to' : $encoding_to = $optarg; break; |
@@ -118,7 +120,7 @@ if ($f_all && empty($argv)) { | ||
118 | 120 | $argv = array_keys(get_existpages('.', $suffix)); |
119 | 121 | } else { |
120 | 122 | foreach ($argv as $arg) { |
121 | - if (! file_exists($arg)) { | |
123 | + if (! $f_nocheck && ! file_exists($arg)) { | |
122 | 124 | echo 'File not found: ' . $arg . "\n"; |
123 | 125 | usage(); |
124 | 126 | } |
@@ -138,10 +140,15 @@ foreach ($argv as $arg) { | ||
138 | 140 | $suffix = ''; |
139 | 141 | } |
140 | 142 | //echo $name . $suffix . "\n"; // As-is |
141 | - //echo decode($name) . $suffix . "\n"; // Decorded | |
142 | - echo encode(mb_convert_encoding(decode($name), | |
143 | - TARGET_ENCODING, SOURCE_ENCODING)) . | |
144 | - $suffix . "\n"; // Decord -> convert -> encode | |
143 | + if ($f_decode) { | |
144 | + // Decord | |
145 | + echo decode($name) . $suffix . "\n"; | |
146 | + } else { | |
147 | + // Decord -> convert -> encode | |
148 | + echo encode(mb_convert_encoding(decode($name), | |
149 | + TARGET_ENCODING, SOURCE_ENCODING)) . | |
150 | + $suffix . "\n"; | |
151 | + } | |
145 | 152 | //echo "\n"; |
146 | 153 | } |
147 | 154 | ?> |