kopia lustrzana https://github.com/backface/turtlestitch
Merge pull request #2931 from jmoenig/michael/utf-8
Better Support Multi-Byte Emoji with `split` and `unicode`snap7
commit
4210201e07
|
@ -922,7 +922,7 @@ List.prototype.asCSV = function () {
|
|||
|
||||
var items = this.itemsArray(),
|
||||
rows = [];
|
||||
|
||||
|
||||
function encodeCell(atomicValue) {
|
||||
var string = isNil(atomicValue) ? '' : atomicValue.toString(),
|
||||
cell;
|
||||
|
@ -932,7 +932,7 @@ List.prototype.asCSV = function () {
|
|||
return string;
|
||||
}
|
||||
cell = ['\"'];
|
||||
string.split('').forEach(letter => {
|
||||
Array.from(string).forEach(letter => {
|
||||
cell.push(letter);
|
||||
if (letter === '\"') {
|
||||
cell.push(letter);
|
||||
|
@ -1094,7 +1094,7 @@ List.prototype.blockify = function (limit = 500, count = [0]) {
|
|||
|
||||
block.isDraggable = true;
|
||||
slots.removeInput();
|
||||
|
||||
|
||||
// fill the slots with the data
|
||||
for (i = 0; i < len && count[0] < limit; i += 1) {
|
||||
value = this.at(i + 1);
|
||||
|
|
|
@ -4344,15 +4344,16 @@ Process.prototype.reportStringSize = function (data) {
|
|||
};
|
||||
|
||||
Process.prototype.reportUnicode = function (string) {
|
||||
var str;
|
||||
var str, unicodeList;
|
||||
|
||||
if (this.enableHyperOps) {
|
||||
if (string instanceof List) {
|
||||
return string.map(each => this.reportUnicode(each));
|
||||
}
|
||||
str = isNil(string) ? '\u0000' : string.toString();
|
||||
if (str.length > 1) {
|
||||
return this.reportUnicode(new List(str.split('')));
|
||||
unicodeList = Array.from(str);
|
||||
if (unicodeList.length > 1) {
|
||||
return this.reportUnicode(new List(unicodeList));
|
||||
}
|
||||
} else {
|
||||
str = isNil(string) ? '\u0000' : string.toString();
|
||||
|
@ -4420,9 +4421,10 @@ Process.prototype.reportBasicTextSplit = function (string, delimiter) {
|
|||
str = str.trim();
|
||||
del = /\s+/;
|
||||
break;
|
||||
case isNil(delimiter):
|
||||
case '':
|
||||
case 'letter':
|
||||
del = '';
|
||||
break;
|
||||
return new List(Array.from(str));
|
||||
case 'csv':
|
||||
return this.parseCSV(string);
|
||||
case 'json':
|
||||
|
@ -4434,7 +4436,7 @@ Process.prototype.reportBasicTextSplit = function (string, delimiter) {
|
|||
return this.parseCSVfields(string);
|
||||
*/
|
||||
default:
|
||||
del = isNil(delimiter) ? '' : delimiter.toString();
|
||||
del = delimiter.toString();
|
||||
}
|
||||
return new List(str.split(del));
|
||||
};
|
||||
|
|
Ładowanie…
Reference in New Issue