Swift
Swift
Ungzip Base64 String
See more Gzip Examples
Suppose you have a gzip in base64 representation that contains a text file, such as XML. This example shows how to decompress and access the string.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let gzip = CkoGzip()!
var gzipBase64: String? = "H4sIAAAAAAAE ... X6aZjXO3EwAA"
let bd = CkoBinData()!
success = bd.appendEncoded(encData: gzipBase64, encoding: "base64")
success = gzip.uncompressBd(binDat: bd)
if success != true {
print("\(gzip.lastErrorText!)")
return
}
var strXml: String? = bd.getString(charset: "utf-8")
print("XML:")
print("\(strXml!)")
}