source: frontend/node_modules/whatwg-url/dist/encoding.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 632 bytes
Line 
1"use strict";
2let { TextEncoder, TextDecoder } = require("util");
3// Handle browserify's lack of support (https://github.com/browserify/node-util/issues/46), which
4// is important for the live viewer:
5if (!TextEncoder) {
6 TextEncoder = global.TextEncoder;
7}
8if (!TextDecoder) {
9 TextDecoder = global.TextDecoder;
10}
11
12const utf8Encoder = new TextEncoder();
13const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });
14
15function utf8Encode(string) {
16 return utf8Encoder.encode(string);
17}
18
19function utf8DecodeWithoutBOM(bytes) {
20 return utf8Decoder.decode(bytes);
21}
22
23module.exports = {
24 utf8Encode,
25 utf8DecodeWithoutBOM
26};
Note: See TracBrowser for help on using the repository browser.