Index: /CKEditor/trunk/_dev/fixlineends/fixlineends.bat
===================================================================
--- /CKEditor/trunk/_dev/fixlineends/fixlineends.bat	(revision 5700)
+++ /CKEditor/trunk/_dev/fixlineends/fixlineends.bat	(revision 5701)
@@ -5,3 +5,3 @@
 ::
 
-php fixlineends.php --excluderegex=/(?:_dev[\\\/]_thirdparty)/ --eolstripwhite --eofnewline --eofstripwhite --nohidden --nosystem ../../
+php fixlineends.php --excluderegex=/(?:_dev[\\\/]_thirdparty)/ --eolstripwhite --eofnewline --eofstripwhite --nohidden --nosystem --fixbom ../../
Index: /CKEditor/trunk/_dev/fixlineends/fixlineends.php
===================================================================
--- /CKEditor/trunk/_dev/fixlineends/fixlineends.php	(revision 5700)
+++ /CKEditor/trunk/_dev/fixlineends/fixlineends.php	(revision 5701)
@@ -64,4 +64,8 @@
 $list["xml"] = CRLF;
 
+$bom = array();
+$bom['asp'] = true;
+$bom['js'] = true;
+
 /**
  * Do not modify anything below
@@ -107,4 +111,9 @@
  */
 $nodotfiles = false;
+/**
+ * If set to true, BOM characters are fixed
+ * @var boolean $fixbom
+ */
+$fixbom = false;
 /**
  * How deep to recurse into subdirectories
@@ -317,4 +326,15 @@
         }
         $new_content .= $line;
+    }
+
+    if ($GLOBALS['fixbom']) {
+        $before_fixing = $new_content;
+        $ext = strtolower(substr($path, strrpos($path, ".") + 1));
+        $new_content = stripUtf8Bom( $new_content );
+        if (!empty($GLOBALS['bom'][$ext])) {
+            $new_content = "\xEF\xBB\xBF" . $new_content; // BOM
+        }
+        if ($new_content != $before_fixing)
+            $modified = true;
     }
 
@@ -353,4 +373,16 @@
 
 /**
+ * Strip BOM from a string
+ * @param string $data
+ */
+function stripUtf8Bom( $data )
+{
+    if ( substr( $data, 0, 3 ) == "\xEF\xBB\xBF" )
+        return stripUtf8Bom(substr_replace( $data, '', 0, 3 )) ;
+
+    return $data ;
+}
+
+/**
  * Fix ending lines in all files at given path
  *
@@ -453,18 +485,21 @@
             use regex to exclude files, preg_match() format expected
 
+       --fixbom
+            fix BOM characters
+
        --help
             display this help and exit
 
        --noarchive
-            if set to true, archive files are skipped (Windows only)
+            skip archive files (Windows only)
 
        --nodotfiles
-            if set to true, dot files are skipped
+            skip dot files
 
        --nohidden
-            if set to true, hidden files are skipped (Windows only)
+            skip hidden files (Windows only)
 
        --nosystem
-            if set to true, system files are skipped (Windows only)
+            skip system files (Windows only)
 
        --maxdepth
@@ -525,4 +560,8 @@
             case '--nodotfiles':
                 $GLOBALS['nodotfiles'] = true;
+                break;
+
+            case '--fixbom':
+                $GLOBALS['fixbom'] = true;
                 break;
 
@@ -572,11 +611,11 @@
 
 if ($_SERVER['argc']>1) {
-	include "../_thirdparty/console_getopt/Getopt.php";
+    include "../_thirdparty/console_getopt/Getopt.php";
 
     if ($windows) {
-        $longoptions = array("eofstripwhite", "eofnewline", "eolstripwhite", "help", "noarchive", "nohidden", "nosystem", "nodotfiles", "maxdepth=", "excluderegex=");
+        $longoptions = array("eofstripwhite", "eofnewline", "eolstripwhite", "help", "noarchive", "nohidden", "nosystem", "nodotfiles", "maxdepth=", "excluderegex=", "fixbom");
     }
     else {
-        $longoptions = array("eofstripwhite", "eofnewline", "eolstripwhite", "help", "nodotfiles", "maxdepth=", "excluderegex=");
+        $longoptions = array("eofstripwhite", "eofnewline", "eolstripwhite", "help", "nodotfiles", "maxdepth=", "excluderegex=", "fixbom");
     }
 
