Skip to content

Commit 1450305

Browse files
committed
Use the correct escape for BOM; add build code to detect non-ASCII.
1 parent 798a7a7 commit 1450305

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

grunt.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,27 @@ module.exports = function( grunt ) {
416416
return path !== "*";
417417
});
418418

419+
// Ensure the dist files are pure ASCII
420+
var fs = require("fs"),
421+
nonascii = false;
422+
distpaths.forEach(function( filename ) {
423+
var buf = fs.readFileSync( filename, "utf8" ),
424+
i, c;
425+
if ( buf.length !== Buffer.byteLength( buf, "utf8" ) ) {
426+
log.writeln( filename + ": Non-ASCII characters detected:" );
427+
for ( i = 0; i < buf.length; i++ ) {
428+
c = buf.charCodeAt( i );
429+
if ( c > 127 ) {
430+
log.writeln( "- position " + i + ": " + c );
431+
log.writeln( "-- " + buf.substring( i - 20, i + 20 ) );
432+
nonascii = true;
433+
}
434+
}
435+
}
436+
});
437+
if ( nonascii ) {
438+
return false;
439+
}
419440

420441
// Proceed only if there are actual
421442
// paths to write to

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ jQuery.extend({
605605
},
606606

607607
// Use native String.trim function wherever possible
608-
trim: core_trim && !core_trim.call("\xFEFF\xA0") ?
608+
trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
609609
function( text ) {
610610
return text == null ?
611611
"" :

0 commit comments

Comments
 (0)