encoding.js 328 B

12345678910111213141516
  1. "use strict";
  2. const utf8Encoder = new TextEncoder();
  3. const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });
  4. function utf8Encode(string) {
  5. return utf8Encoder.encode(string);
  6. }
  7. function utf8DecodeWithoutBOM(bytes) {
  8. return utf8Decoder.decode(bytes);
  9. }
  10. module.exports = {
  11. utf8Encode,
  12. utf8DecodeWithoutBOM
  13. };