From 1450305402ee8f36825fd5fa44df913a3be2f4c8 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Thu, 11 Oct 2012 10:17:24 -0400 Subject: [PATCH] Use the correct escape for BOM; add build code to detect non-ASCII. --- grunt.js | 21 +++++++++++++++++++++ src/core.js | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/grunt.js b/grunt.js index 53d990fb0..7ccf49f95 100644 --- 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 diff --git a/src/core.js b/src/core.js index 73c24dc9b..709467168 100644 --- a/src/core.js +++ b/src/core.js @@ -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 ? "" : -- 2.39.5