handle dwidth characters.

This commit is contained in:
Christopher Jeffrey 2013-07-28 03:18:00 -05:00
parent a82ad19110
commit db46a020a3

View File

@ -2052,6 +2052,15 @@ Element.prototype._wrapContent = function(content, width) {
}
}
//for (i = 0; i < line.length; i++) {
// if (isDwidth(line[i])) {
// line = line.substring(0, i) + line[i] + '\0' + line.substring(i + 1);
// i++;
// }
//}
line = line.replace(dwidthChars, '$1\0');
if (!wrap && line.length > width) {
line = line.slice(0, width);
}
@ -2826,6 +2835,10 @@ Element.prototype.render = function() {
}
}
if (ch === '\0') {
continue;
}
// Handle newlines.
if (ch === '\t') ch = ' ';
if (ch === '\n') {
@ -5466,6 +5479,30 @@ function hsort(obj) {
});
}
var dwidthChars = new RegExp('(['
+ '\\uff01-\\uffbe'
+ '\\uffc2-\\uffc7'
+ '\\uffca-\\uffcf'
+ '\\uffd2-\\uffd7'
+ '\\uffda-\\uffdc'
+ '\\uffe0-\\uffe6'
+ '\\uffe8-\\uffee'
+ '])', 'g');
function isDwidthR(ch) {
return dwidthChars.test(ch);
}
function isDwidth(ch) {
return (ch >= '\uff01' && ch <= '\uffbe')
|| (ch >= '\uffc2' && ch <= '\uffc7')
|| (ch >= '\uffca' && ch <= '\uffcf')
|| (ch >= '\uffd2' && ch <= '\uffd7')
|| (ch >= '\uffda' && ch <= '\uffdc')
|| (ch >= '\uffe0' && ch <= '\uffe6')
|| (ch >= '\uffe8' && ch <= '\uffee');
}
/**
* Expose
*/