UNPKG

@kayahr/text-encoding

Version:
25 lines 709 B
/* * Copyright (C) 2021 Klaus Reimer <k@ailis.de> * See LICENSE.md for licensing information. */ import { AbstractDecoder } from "../AbstractDecoder.js"; import { END_OF_BUFFER } from "../ByteBuffer.js"; import { FINISHED } from "../constants.js"; import { isASCII } from "../util.js"; /** * Decoder for x-user-defined encoding. */ export class XUserDefinedDecoder extends AbstractDecoder { /** @inheritdoc */ decode(buffer) { const byte = buffer.read(); if (byte === END_OF_BUFFER) { return FINISHED; } if (isASCII(byte)) { return byte; } return 0xF780 + byte - 0x80; } } //# sourceMappingURL=XUserDefinedDecoder.js.map