Merge pull request #2931 from jmoenig/michael/utf-8

Better Support Multi-Byte Emoji with `split` and `unicode`
snap7
Jens Mönig 2021-12-15 08:24:49 +01:00 zatwierdzone przez GitHub
commit 4210201e07
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -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);

Wyświetl plik

@ -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));
};