Special symbol which breaks IE9

by alekskorovin

JavaScript

var ascii = /^[ -~]+$/;
//not ascii
var str = '[email protected]‏';

// remove last symbol
//var str = '[email protected]';

//var str = '[email protected]';
if ( !ascii.test( str ) ) {
  // string has non-ascii characters
    alert('not ascii');
}

for (var i=0; i < str.length; i++) {
     var n = str.charCodeAt(i);
    console.log(n);
}