![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Unicode C++) Compress String Feed to Base64This example receives incoming text data in chunks, compresses as a stream, and accumulates the compressed data in base64. Note: This example requires Chilkat v11.0.0 or greater.
#include <CkStringBuilderW.h> #include <CkCompressionW.h> #include <CkBinDataW.h> void ChilkatSample(void) { bool success = false; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkStringBuilderW sbCompressedBase64; CkCompressionW compress; compress.put_Algorithm(L"deflate"); compress.put_Charset(L"utf-8"); compress.put_EncodingMode(L"base64"); compress.put_FirstChunk(true); compress.put_LastChunk(false); CkBinDataW bdCompressed; CkStringBuilderW sbUncompressedChunk; int i; for (i = 0; i <= 24; i++) { if (i == 24) { compress.put_LastChunk(true); } sbUncompressedChunk.Clear(); sbUncompressedChunk.AppendInt(i); sbUncompressedChunk.Append(L": This is a line of data to be compressed...\r\n"); compress.CompressSb(sbUncompressedChunk,bdCompressed); compress.put_FirstChunk(false); } wprintf(L"The base64 encoded compressed text:\n"); wprintf(L"%s\n",bdCompressed.getEncoded(L"base64")); // Decompress in one call: const wchar_t *originalText = compress.decompressStringENC(bdCompressed.getEncoded(L"base64")); wprintf(L"%s\n",originalText); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.