]> git.ardis.lu - utf-8-visualizer/commitdiff
Simplify 1 byte encodings
authorArdis Lu <ardisglu@gmail.com>
Fri, 6 Jan 2023 09:07:37 +0000 (01:07 -0800)
committerArdis Lu <ardisglu@gmail.com>
Fri, 6 Jan 2023 09:07:37 +0000 (01:07 -0800)
Markings not required because the encoding is equal to the code point

script.js

index 5662c1a162b472b06c9068d5c0b1c8913e568988..76329b6504b2bbef34800725dc310d709a986668 100644 (file)
--- 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 `<span class="insignificant">0</span><span class="significant">${bytes[0].substring(2)}</span>`;
+    return `<span class="significant">${bytes[0]}</span>`;
   }
 
   // All other UTF-8 byte lengths follow the same pattern
This page took 0.037218 seconds and 4 git commands to generate.