Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) Append Encoded Binary Data to StringBuilderDemonstrates how to append encoded binary data to the contenets of a StringBuilder.
#include <C_CkBinData.h> #include <C_CkStringBuilder.h> void ChilkatSample(void) { HCkBinData bd; BOOL success; HCkStringBuilder sb; bd = CkBinData_Create(); success = CkBinData_LoadFile(bd,"qa_data/jpg/starfish.jpg"); if (success == FALSE) { printf("Failed to load file.\n"); CkBinData_Dispose(bd); return; } // For example, let's say we want construct simple JSON containing the base64 representation of the above JPG file. sb = CkStringBuilder_Create(); CkStringBuilder_Append(sb,"{ \"jpg\": \""); // GetEncodedSb appends the enocded representation of the binary data to the StringBuiler passed in the 2nd arg. CkBinData_GetEncodedSb(bd,"base64",sb); CkStringBuilder_Append(sb,"\" }"); printf("%s\n",CkStringBuilder_getAsString(sb)); // Output looks like this: // { "jpg": "/9j/4AAQSkZJRgABAg...rcQ+vo//2Q==" } CkBinData_Dispose(bd); CkStringBuilder_Dispose(sb); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.