move utf32ToString to TextDecoder.ts

This commit is contained in:
Jörg Breitbart
2019-01-25 17:35:12 +01:00
parent 21165a4286
commit 4855b60ffe
7 changed files with 86 additions and 93 deletions
+1 -21
View File
@@ -2,10 +2,7 @@
* Copyright (c) 2018 The xterm.js authors. All rights reserved.
* @license MIT
*/
type TypedArray = Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray
| Int8Array | Int16Array | Int32Array
| Float32Array | Float64Array;
import { TypedArray } from './Types';
/**
* polyfill for TypedArray.fill
@@ -49,20 +46,3 @@ export function concat<T extends TypedArray>(a: T, b: T): T {
result.set(b, a.length);
return result;
}
/**
* Convert UTF32 char codes into JS string.
*/
export function utf32ToString<T extends TypedArray>(data: T, start: number = 0, end: number = data.length): string {
let result = '';
let cp;
for (let i = start; i < end; ++i) {
if ((cp = data[i]) > 0xFFFF) {
cp -= 0x10000;
result += String.fromCharCode((cp >> 10) + 0xD800) + String.fromCharCode((cp % 0x400) + 0xDC00);
} else {
result += String.fromCharCode(cp);
}
}
return result;
}