(VBScript) Ungzip Base64 String
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.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Gzip")
set gzip = CreateObject("Chilkat.Gzip")
gzipBase64 = "H4sIAAAAAAAE ... X6aZjXO3EwAA"
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.BinData")
set bd = CreateObject("Chilkat.BinData")
success = bd.AppendEncoded(gzipBase64,"base64")
success = gzip.UncompressBd(bd)
If (success <> 1) Then
outFile.WriteLine(gzip.LastErrorText)
WScript.Quit
End If
strXml = bd.GetString("utf-8")
outFile.WriteLine("XML:")
outFile.WriteLine(strXml)
outFile.Close
|