Are zlib.compress on Python and Deflater.deflate on Java (Android) compatible?

前端 未结 3 427
醉梦人生
醉梦人生 2020-12-20 18:49

I am porting a Python application to Android and, at some point, this application has to communicate with a Web Service, sending it compressed data.

In order to do t

3条回答
  •  萌比男神i
    2020-12-20 19:30

    Does byte[] input = stringToCompress.getBytes("utf-8"); help? In case your platform's default encoding is not UTF-8, this will force the encoding String -> bytes to use UTF-8. Also, the same goes for the last line of your code where you create a new String - you may want to explicitly specify UTF-8 as the decoding Charset.

提交回复
热议问题