From: Ardis Lu Date: Fri, 6 Jan 2023 09:07:37 +0000 (-0800) Subject: Simplify 1 byte encodings X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=dfb1cb42f15fa8a195ee0a35e9079ca5b14efdca;p=utf-8-visualizer Simplify 1 byte encodings Markings not required because the encoding is equal to the code point --- diff --git a/script.js b/script.js index 5662c1a..76329b6 100644 --- a/script.js +++ b/script.js @@ -40,8 +40,9 @@ function calculateOutput(input) { function parseBytes(bytes) { // A UTF-8 encoded code point with a byte length of 1 is always encoded with this pattern: 0xxxxxxx + // Do not mark first bit insignificant because the UTF-8 encoding is exactly equal to the code point binary if (bytes.length === 1) { - return `0${bytes[0].substring(2)}`; + return `${bytes[0]}`; } // All other UTF-8 byte lengths follow the same pattern