Index: branches/comu/convert.php
===================================================================
--- branches/comu/convert.php	(revision 11974)
+++ branches/comu/convert.php	(revision 12040)
@@ -4,26 +4,53 @@
  * ¥Õ¥¡¥¤¥ë¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ò $fromEncoding ¤«¤é $toEncoding ¤ØÊÑ´¹¤·¤Þ¤¹.
  *
- * @version $Revision$ $Date$
- * @author  Kentaro Ohkouchi
+ * @author  Kentaro Ohkouchi<ohkouchi@loop-az.jp>
+ * @since   PHP4.3.0(cli)
+ * @version $Id$
  */
 
-/** include files suffix. */
-$includes = ".php,.inc,.tpl,.css,.sql";
+/**
+ * ÊÑ´¹¤·¤¿¤¤¥Õ¥¡¥¤¥ë¤Î³ÈÄ¥»Ò¤ò¥«¥ó¥Þ¶èÀÚ¤ê¤ÇÍåÎó.
+ */
+$includes = "php,inc,tpl,css,sql,js";
 
-/** convert from encoding. */
+/**
+ * ½ü³°¤¹¤ë¥Õ¥¡¥¤¥ëÌ¾¤ò¥«¥ó¥Þ¶èÀÚ¤ê¤ÇÍåÎó.
+ */
+$excludes = "convert.php";
+
+/**
+ * ÊÑ´¹¸µ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°.
+ */
 $fromEncoding = "EUC-JP";
-/** convert to encoding. */
+
+/**
+ * ÊÑ´¹Àè¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°.
+ */
 $toEncoding = "UTF-8";
 
 $includeArray = explode(',', $includes);
+$excludeArray = explode(',', $excludes);
 $fileArrays = listdirs('.');
 
 foreach ($fileArrays as $path) {
     if (is_file($path)) {
-        $fileName = basename($path);
-        $suffix = substr($fileName, -4);
 
+        // ¥Õ¥¡¥¤¥ëÌ¾¤ò¼èÆÀ
+        $fileName = pathinfo($path, PATHINFO_BASENAME);
+        
+        // ³ÈÄ¥»Ò¤ò¼èÆÀ
+        $suffix = pathinfo($path, PATHINFO_EXTENSION);
+
+        // ½ü³°¥Õ¥¡¥¤¥ë¤ò¥¹¥­¥Ã¥×
+        if (in_array($fileName, $excludeArray)) {
+            echo "excludes by " . $path . "\n";
+            continue;
+        }
+
+        // ÊÑ´¹ÂÐ¾Ý¤ò½ç¤Ë½èÍý
         foreach ($includeArray as $include) {
             if ($suffix == $include) {
+            	
+            	// ¥Õ¥¡¥¤¥ëÆâÍÆ¤ò¼èÆÀ¤·, ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°ÊÑ´¹
                 $contents = file_get_contents($path);
                 $convertedContents = mb_convert_encoding($contents,
@@ -31,7 +58,8 @@
                                                          $fromEncoding);
 
+                // ½ñ¤­¹þ¤ß¤Ç¤­¤ë¤«¡©
                 if (is_writable($path)) {
 
-                    // file open
+                    // ¥Õ¥¡¥¤¥ë¤ò½ñ¤­½Ð¤·¥â¡¼¥É¤Ç³«¤¯
                     $handle = fopen($path, "w");
                     if (!$handle) {
@@ -40,4 +68,5 @@
                     }
 
+                    // ¥³¡¼¥ÉÊÑ´¹¤·¤¿ÆâÍÆ¤ò½ñ¤­¹þ¤à 
                     if (fwrite($handle, $convertedContents) === false) {
                         echo "Cannot write to file (" . $path . ")";
@@ -46,4 +75,5 @@
 
                     echo "converted " . $path . "\n";
+                    // ¥Õ¥¡¥¤¥ë¤òÊÄ¤¸¤ë
                     fclose($handle);
                 } else {
@@ -56,4 +86,11 @@
 }
 
+/**
+ * $dir ¤òºÆµ¢Åª¤ËÃ©¤Ã¤Æ¥Ñ¥¹Ì¾¤òÇÛÎó¤ÇÊÖ¤¹.
+ * 
+ * @param string Ç¤°Õ¤Î¥Ñ¥¹Ì¾
+ * @return array $dir ¤è¤ê²¼ÁØ¤ËÂ¸ºß¤¹¤ë¥Ñ¥¹Ì¾¤ÎÇÛÎó
+ * @see http://www.php.net/glob
+ */
 function listdirs($dir) {
     static $alldirs = array();
@@ -66,3 +103,2 @@
 }
 ?>
-
