How can I encode a string like 9123456789abcdefghijklmnopqrstuv in 9 string and then decode it into idle?
Actually my entry is a random combination of character included in the string example, I want to shorten it in string form and then interpret it univocally back.
Character set "0123456789abcdefghijklmnopqrstuv" has 32 different characters. 32 ^ 23 (approximately 4 * 10 ^ 34) are different Strings that are 23 letters long, and specifically compose the above characters.
There are 256 ^ 9 (approximately 4 * 10 ^ 21) 9 string which is 9 characters long, and ASCII is significantly larger than 4e34 4e21, therefore, the first type of string is another type of string There is no way to involve in a lossless form, and there is no way which is clearly decoding Cisco first way in the first place.
Although you can not remove it, some compression is still possible. You can get around 5/8 th improve by bit packing.
Start by converting your characters into numbers. East. H is the number 17 in its character set, so it becomes 17. Hello [17, 14, 21, 21, 24]
Remember the number in each binary number five pad for each value. [17, 14, 21, 21, 24] [10001, 01110, 10101, 10101, 11000]
Add binary to a great value. <10001, 01110, 10101, 10101, 11000] 1000101110101011010111000
Split values into squares, eight digits
1000101110101011010111000 1 00010111 01010110 10111000
Convert each section to decimal.
1 00010111 01010110 10111000 [1, 23, 86, 184]
Change each number to its respective ASCII values. [1, 23, 86, 184] ['\ x01', '\ x17', 'V', '\ xb8']
You now have your five character sequence "Hello" The four character sequence is compressed in "\ x01 \ x17V \ xb8".
Comments
Post a Comment