image-in-browser
Version:
Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)
24 lines • 873 B
JavaScript
import { LibError } from '../error/lib-error.js';
export class StringUtils {
static getCodePoints(str) {
const array = new Uint8Array(str.length);
for (let i = 0; i < str.length; i++) {
const codePoint = str.codePointAt(i);
if (codePoint !== undefined) {
if (0 <= codePoint && codePoint < 256) {
array[i] = codePoint;
}
else {
throw new LibError(`Error encoding text "${str}": unknown character code point ${codePoint}`);
}
}
else {
throw new LibError(`Error encoding text "${str}"`);
}
}
return array;
}
}
StringUtils.utf8Decoder = new TextDecoder('utf8');
StringUtils.latin1Decoder = new TextDecoder('latin1');
//# sourceMappingURL=string-utils.js.map