Escape invalid UTF8 characters simon987/sist2#44, increase magic buffer size

This commit is contained in:
2020-05-12 19:28:02 -04:00
parent 013423424e
commit cf513b4ad8
14 changed files with 528 additions and 385 deletions

View File

@@ -64,3 +64,25 @@ function lum(c) {
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
}
function strUnescape(str) {
let result = "";
for (let i = 0; i < str.length; i++) {
const c = str[i];
const next = str[i+1];
if (c === ']') {
if (next === ']') {
result += c;
i += 1;
} else {
result += String.fromCharCode(parseInt(str.slice(i, i + 2), 16));
i += 2;
}
} else {
result += c;
}
}
return result;
}