Show UTF-8 bytes instead of "chars" in status bar

This commit is contained in:
Mikko Ahlroth 2022-10-26 13:52:14 +03:00
parent a5f4b813ce
commit 73d6fd557d
2 changed files with 5 additions and 4 deletions

View file

@ -20,7 +20,7 @@
<div id="length">Waiting...</div>
<div id="info">
v1.0.1 | © Nicd 2022 | <a href="https://gitlab.com/Nicd/tahnaroskakori" target="_blank">Source</a> | <a
v1.1.0 | © Nicd 2022 | <a href="https://gitlab.com/Nicd/tahnaroskakori" target="_blank">Source</a> | <a
href="./licenses.txt" target="_blank">Licenses</a>
</div>
</footer>

View file

@ -48,13 +48,14 @@ function maxHashLength() {
/**
* Compress the given data in a synchronous way (all at once) and update the status.
* @param {Uint8Array} data
* @param {string} data
*/
async function syncCompress(data) {
const compressed = compress(ENCODER.encode(data), { quality: QUALITY });
const utf8 = ENCODER.encode(data);
const compressed = compress(utf8, { quality: QUALITY });
const encoded = BASE66CODEC.encode(compressed);
statusEl.textContent = `Length: ${data.length} chars -> ${compressed.length} bytes -> ${encoded.length}/${maxHashLength()} chars`;
statusEl.textContent = `Length: ${utf8.length} B -> ${compressed.length} B -> ${encoded.length}/${maxHashLength()} chars`;
if (encoded.length <= maxHashLength()) {
history.replaceState(null, "", `#${encoded}`);