|
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";
|
|---|
| 2 | let { 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:
|
|---|
| 5 | if (!TextEncoder) {
|
|---|
| 6 | TextEncoder = global.TextEncoder;
|
|---|
| 7 | }
|
|---|
| 8 | if (!TextDecoder) {
|
|---|
| 9 | TextDecoder = global.TextDecoder;
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | const utf8Encoder = new TextEncoder();
|
|---|
| 13 | const utf8Decoder = new TextDecoder("utf-8", { ignoreBOM: true });
|
|---|
| 14 |
|
|---|
| 15 | function utf8Encode(string) {
|
|---|
| 16 | return utf8Encoder.encode(string);
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | function utf8DecodeWithoutBOM(bytes) {
|
|---|
| 20 | return utf8Decoder.decode(bytes);
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | module.exports = {
|
|---|
| 24 | utf8Encode,
|
|---|
| 25 | utf8DecodeWithoutBOM
|
|---|
| 26 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.