Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
I want to reduce the number of characters of a string of about 20 characters. How can it be possible.? What all possibilities are there.?
NOTE: I am not interested in its size. I just want it to be containing less number of characters and When it is uncompressed I should get back the original string.
Posted

Compression in general is a little bit more complicated than that. But there is one, that might look like what you described, it is called run-length encoding[^].
 
Share this answer
 
Comments
Maciej Los 24-Mar-13 6:05am    
A 5! Pretty good answer for unclear question ;)
Zoltán Zörgő 24-Mar-13 14:57pm    
Thank you!
As Zoltan wrote, it's not so easy... especially when you do not provided enough information.

Some usefull examples, you'll find here:
A Simple String Compression Algorithm[^]
Easy String Compression and Encryption[^]

Interesting alternative is SMAZ[^] - simple compression library suitable for compressing very short strings. It works better with English and it's not general purpose for compressing string data.

You can always use zip, gzip, 7-zip (and other) libraries to compress/decompress data.
 
Share this answer
 
Comments
Zoltán Zörgő 24-Mar-13 14:58pm    
My 5! Your answer higlights also interesting alternatives... I am really curious, what the OP actually wanted...
Maciej Los 24-Mar-13 14:59pm    
Thank you, Zoltan ;)
The problem here is that the input string is not known but I only know its size i.e it has 20 characters. I want this solution for mobile activation for registration. So for this if the characters in the string can be reduced then it will be easy to text for the user. I think now the problem is clear.
 
Share this answer
 
Comments
Maciej Los 25-Mar-13 11:10am    
This is not an answer. Plase, use "Have a question or comment" widget to related answer/solution or "Improve question" widget to update your question. Please, delete this solution.
Maciej Los 25-Mar-13 13:50pm    
No, problem still is not clear. SMAZ algorithm is two-way. It can compress any string and decompress it:
int smaz_compress(char *in, int inlen, char *out, int outlen);
int smaz_decompress(char *in, int inlen, char *out, int outlen);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900