diff --git a/lib/unicode.js b/lib/unicode.js index f98d89a..25fc24a 100644 --- a/lib/unicode.js +++ b/lib/unicode.js @@ -106,6 +106,10 @@ var stringFromCharCode = String.fromCharCode; var floor = Math.floor; +/** + * Wide, Surrogates, and Combining + */ + exports.charWidth = function(str, i) { var point = typeof str !== 'number' ? exports.codePointAt(str, i || 0) @@ -447,21 +451,9 @@ exports.isNonSpacing = function(str, i) { return exports.combining[point] === true; }; -/* -exports.codePointAt = function(str, position) { - position = +position || 0; - var x = str.charCodeAt(position); - var y = str.length > 1 ? str.charCodeAt(position + 1) : 0; - var point = x; - if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) { - x &= 0x3FF; - y &= 0x3FF; - point = (x << 10) | y; - point += 0x10000; - } - return point; -}; -*/ +/** + * Code Point Helpers + */ exports.codePointAt = function(str, position) { if (str == null) { @@ -494,6 +486,20 @@ exports.codePointAt = function(str, position) { return first; }; +// exports.codePointAt = function(str, position) { +// position = +position || 0; +// var x = str.charCodeAt(position); +// var y = str.length > 1 ? str.charCodeAt(position + 1) : 0; +// var point = x; +// if ((0xD800 <= x && x <= 0xDBFF) && (0xDC00 <= y && y <= 0xDFFF)) { +// x &= 0x3FF; +// y &= 0x3FF; +// point = (x << 10) | y; +// point += 0x10000; +// } +// return point; +// }; + exports.fromCodePoint = function() { var MAX_SIZE = 0x4000; var codeUnits = []; diff --git a/lib/widget.js b/lib/widget.js index 1261e86..6eb19e5 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2432,6 +2432,7 @@ Element.prototype.parseContent = function(noTags) { // NOTE: We could drop this, the non-surrogates would get changed to ? by // the unicode filter, and surrogates changed to ? by the surrogate // regex. however, the user might expect them to be 0-width. + // NOTE: Might be better for performance to drop! content = content.replace(unicode.chars.combining, ''); // no surrogate pairs: replace them with question-marks. content = content.replace(unicode.chars.surrogate, '?'); diff --git a/test/widget-eaw.js b/test/widget-eaw.js index 67c2f6f..ef9e8b4 100644 --- a/test/widget-eaw.js +++ b/test/widget-eaw.js @@ -101,7 +101,7 @@ lorem = lorem.replace(/e/gi, DOUBLE); //lorem = lorem.replace(/r/gi, JUAN); // NOTE: libvte breaks when trying to display // this surrogate pair double width character: -if (~process.argv.indexOf('vte')) { +if (!~process.argv.indexOf('vte')) { lorem = lorem.replace(/a/gi, SURROGATE_DOUBLE); } lorem = lorem.replace(/o/gi, SURROGATE_SINGLE);