As the title says,i am using GZip to compress and decompress the string.But in between that i want to read the compressed string,how do i read that unknown compressed string?.
What i tried so far:
Using GZip(from github),i tried compressing the string as below...
//UML string
NSString *plantUmlString = @"@startuml\n Bob -> Alice : hello \n@enduml"
String compression...
NSData *originalData = [plantUmlString dataUsingEncoding:NSASCIIStringEncoding];
NSString *compressedString = [[originalData gzippedData] base64EncodedStringWithOptions:kNilOptions];
NSLog(@"%@", compressedString);//H4sIAAAAAAAAA8tIzcnJV0gvrSwuKcrMSw8tBhKuecn5KQCRj54cGQAAAA
Where i am struggling:
compressedString is returning "H4sIAAAAAAAAA8tIzcnJV0gvrSwuKcrMSw8tBhKuecn5KQCRj54cGQAAAA" instead of "SzIrIxBAICt9oGS0",this is the actual string i should get.If i decode the generated compressedString,i am getting nill...And if i use UTF-8 encoding i am getting "null"..How do i read the actuall string here?
NOTE: if i decompress the above compressed data,i am getting original string before compressing...
NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:compressedString options:0];
NSString *decompressedString=[[NSString alloc] initWithData:[decodedData gunzippedData] encoding:NSASCIIStringEncoding];
NSLog(@"%@",decompressedString);
//Correct: decompressedString returning me the original string before compressing...
What i am trying to do:
Trying to generate a flowchart using the PlantUML Server,which accepts the compressed UML string and returns me the flowchart image...
Some more information : If i compress the above UML string in android(which is available in github) i am getting "SzIrIxBAICt9oGS0" as the string...But in Objective-C i am reading entirely different string...
Am i doing something worng with the encoding?...Any advice/solution is really helpful...
According to the sample code at http://plantuml.sourceforge.net/codephp.html , it uses compression level 9, so you probably want to use that, if you want to exactly match that string.