Unicode C++
Unicode C++
Base64 Encode a File
_LANGUAGE_ to Base64 encode the contents of a file.Chilkat Unicode C++ Downloads
#include <CkFileAccessW.h>
void ChilkatSample(void)
{
bool success = false;
// Get the contents of a file into a base64 encoded string:
CkFileAccessW fac;
const wchar_t *strBase64 = fac.readBinaryToEncoded(L"c:/data/something.pdf",L"base64");
if (fac.get_LastMethodSuccess() != true) {
wprintf(L"%s\n",fac.lastErrorText());
return;
}
// Now write the string to a file:
success = fac.WriteEntireTextFile(L"c:/data/something_pdf_base64.txt",strBase64,L"us-ascii",false);
if (success != true) {
wprintf(L"%s\n",fac.lastErrorText());
return;
}
wprintf(L"Success!\n");
}