I have a vb.net function for compressing string, and return the result as a string.
And result my compressed string: ""Hello World" -> CwAAAB+LCAAAAAAABADzSM3JyVcIzy/KSQEAVrEXSgsAAAA=
But I can not decompress my string in B4A:
B4X:
Public Shared Function Zip(text As String) As String
Dim buffer As Byte() = System.Text.Encoding.UTF8.GetBytes(text)
Dim ms As New MemoryStream()
Using zipStream As New System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Compress, True)
zipStream.Write(buffer, 0, buffer.Length)
End Using
ms.Position = 0
Dim outStream As New MemoryStream()
Dim compressed As Byte() = New Byte(ms.Length - 1) {}
ms.Read(compressed, 0, compressed.Length)
Dim gzBuffer As Byte() = New Byte(compressed.Length + 3) {}
System.Buffer.BlockCopy(compressed, 0, gzBuffer, 4, compressed.Length)
System.Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, gzBuffer, 0, 4)
Return Convert.ToBase64String(gzBuffer)
End Function
And result my compressed string: ""Hello World" -> CwAAAB+LCAAAAAAABADzSM3JyVcIzy/KSQEAVrEXSgsAAAA=
But I can not decompress my string in B4A:
B4X:
Dim str1 As String = "CwAAAB+LCAAAAAAABADzSM3JyVcIzy/KSQEAVrEXSgsAAAA="
Dim SU As StringUtils
Dim data() As Byte = SU.DecodeBase64(str1)
fulltext = BytesToString(data, 0, data.Length, "UTF8")