0

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?

Kate Orlova
  • 3,225
  • 5
  • 11
  • 35
Amin
  • 681
  • 4
  • 9
  • 27
  • 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
  • 1
    You'll get better results when searching for *compression/decompression*, not encoding/decoding. – Bergi Jul 06 '19 at 14:13

1 Answers1

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