]> source.dussan.org Git - jquery.git/commitdiff
Use the correct escape for BOM; add build code to detect non-ASCII.
authorDave Methvin <dave.methvin@gmail.com>
Thu, 11 Oct 2012 14:17:24 +0000 (10:17 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Thu, 11 Oct 2012 14:25:43 +0000 (10:25 -0400)
grunt.js
src/core.js

index 53d990fb018c52bddb572cb69513f8e67cb887bf..7ccf49f95176d59d5daf961752f81f66c95138df 100644 (file)
--- a/grunt.js
+++ b/grunt.js
@@ -416,6 +416,27 @@ module.exports = function( grunt ) {
                        return path !== "*";
                });
 
+               // Ensure the dist files are pure ASCII
+               var fs = require("fs"),
+                       nonascii = false;
+               distpaths.forEach(function( filename ) {
+                       var buf = fs.readFileSync( filename, "utf8" ),
+                       i, c;
+                       if ( buf.length !== Buffer.byteLength( buf, "utf8" ) ) {
+                               log.writeln( filename + ": Non-ASCII characters detected:" );
+                               for ( i = 0; i < buf.length; i++ ) {
+                                       c = buf.charCodeAt( i );
+                                       if ( c > 127 ) {
+                                               log.writeln( "- position " + i + ": " + c );
+                                               log.writeln( "-- " + buf.substring( i - 20, i + 20 ) );
+                                               nonascii = true;
+                                       }
+                               }
+                       }
+               });
+               if ( nonascii ) {
+                       return false;
+               }
 
                // Proceed only if there are actual
                // paths to write to
index 73c24dc9bae694075e58ae5fde06eae2b163f7d7..709467168907bf67568176049b9449730c932ab6 100644 (file)
@@ -605,7 +605,7 @@ jQuery.extend({
        },
 
        // Use native String.trim function wherever possible
-       trim: core_trim && !core_trim.call("\xFEFF\xA0") ?
+       trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
                function( text ) {
                        return text == null ?
                                "" :