java - Inflating Delfated Hex String -
java - Inflating Delfated Hex String -
i'm using deflater class compress string.
i need convert ascii string hexadecimal string. how convert ascii string can decompress using inflater receive original string?
my problem backwards conversion doesn't equal original due encoding (?) or something.
test code:
string compressed = compressor.compress("stackoverflow.com"); system.out.println("compressed ascii: " + compressed); string converted = converter.asciitohex(compressed); system.out.println("compressed hex: " + converted); system.out.println("compressed ascii: " + converter.hextoascii(converted)); output:
compressed ascii: xœ+.ilÎÎ/k-jËÉ/×kÎÏ compressed hex: 789c2b2e494ccece2f4b2d4acbc92fd74bcecf05003ff306f8 compressed ascii: x?+.ilÎÎ/k-jËÉ/×kÎÏ notice how 2nd character ? instead of œ? why not converted properly? how can fixed?
the "faulty" method:
public static string hextoascii(string hex) { stringbuilder output = new stringbuilder(); (int = 0; < hex.length(); += 2) { string str = hex.substring(i, + 2); output.append((char) integer.parseint(str, 16)); } homecoming output.tostring(); } java zlib
Comments
Post a Comment