2

yEnc is a binary-to-text encoding scheme for transferring binary files in messages... yEnc's overhead is often (if each byte value appears approximately with the same frequency on average) as little as 1–2%,1 compared to 33–40% overhead for 6-bit encoding methods like uuencode and Base64.
https://en.wikipedia.org/wiki/YEnc

I use this lib for yEnc encode https://www.npmjs.com/package/simple-yenc

What I am doing wrong.
This browser test encode image to string

/** @param {Blob} img */
const test = img => {
    // yEnc
    img.arrayBuffer()
        .then(arrayBuffer => console.log(dynamicEncode(new Uint8Array(arrayBuffer))));

    // base64
    const reader = new FileReader();
    reader.onloadend = () => console.log(reader.result);
    reader.readAsDataURL(img);
};

yEnc string is 5.5 MB
base64 string is 4.7 MB

test result

My goal is to store image in JSON.

1
  • You should probably provide a sample input that demonstrates this issue. Since yEnc works by escaping certain values while leaving others intact, perhaps your input just happens to have a large population of those particular symbols that are escaped, but this is just guesswork on my part. Commented Oct 30 at 18:42

1 Answer 1

0

As I understand, yEnc don't work with UTF-8.

It is not really binary-to-text though, it is more "binary to binary which can pass through common NNTP servers/clients as long as common encodings like latin1 are used" The last part is critical - yEnc is incompatible with more complex encodings like UTF-8, which is why it is completely useless today.
https://news.ycombinator.com/item?id=34680371

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.