encode ASCII symbols into UTF-8 presentation


I have a string that I k’now for sure has only ASCII lettes.
JS treats strings as UTF-8 by default,
so it means that every character takes up to 4 bytes,
which is 4 times ASCII.

I’m trying to compress / save spaces / get the shortest string as possible,
by having an encode and decode functions.

I thought about representing 4 characters of ASCII on a UTF-8 string and by that achieve my goals, is there anything like that?
UTS-8 compressed to ASCII

If not, what is the best way to compress ASCII strings, so that by encoding and decoding I’ll reach the same string?

Source: JavaSript – Stack Overflow

September 24, 2021
Category : News
Tags: ascii | compression | encoding | javascript | utf-8

encode ASCII symbols into UTF-8 presentation


I have a string that I k’now for sure has only ASCII lettes.
JS treats strings as UTF-8 by default,
so it means that every character takes up to 4 bytes,
which is 4 times ASCII.

I’m trying to compress / save spaces / get the shortest string as possible,
by having an encode and decode functions.

I thought about representing 4 characters of ASCII on a UTF-8 string and by that achieve my goals, is there anything like that?
UTS-8 compressed to ASCII

If not, what is the best way to compress ASCII strings, so that by encoding and decoding I’ll reach the same string?

Source: JavaSript – Stack Overflow

September 24, 2021
Category : News
Tags: ascii | compression | encoding | javascript | utf-8

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.