I have a very big string and want to encode it in a smaller one. Then I want to decode it again. How to do this?
Asked
Active
Viewed 2,246 times
0
-
What you are asking for is in general simply impossible by basic information theory. What is possible is to map *some* strings to smaller strings in an invertible way, but at the cost of actually expanding other strings. – John Coleman Jul 06 '19 at 12:49
-
1You'll get better results when searching for *compression/decompression*, not encoding/decoding. – Bergi Jul 06 '19 at 14:13
1 Answers
0
From what I understand, you are trying to achieve compression
of a string that is bigger in size than you want it to be. This is not as easy as it seems. However, there are some resources available online.
Similar question: String compression in JavaScript
A JS tool for compression: http://pieroxy.net/blog/pages/lz-string/index.html
Lempel–Ziv–Welch compression algorithm: https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch

Devashish
- 1,260
- 1
- 10
- 21