Decode a base64 encoded string.
Decode a base64 encoded string. The result must deleted using release.
Name | Type | Default | Description |
Return | char* | New created char* string with the decoded input string. Must released using release! | |
txt | char* | - | any base64 encoeded char* string |
binary | int | 0 | Decode binary data? When this parameter is set to 1, the result contains zeros and the terminating zero is omitted. In this case you should make use of the output parameter oLength to determine the length of the result buffer. |
oLength | int * | 0 | Result length of the decoded data. Important when decoding binary data where strlen is not usable. |
useSOAPDecoder | int | 0 | You will hardly ever need the parameter, but just in case: If the parameter has a value other than 0, exactly the same decoder is used as in SOAP. In Illustrator, the parameter is ignored and the default decoding method is always used. |
Encoding the current text and decoding this result must be equal.
int main () { String str = string::alloc (); char * enc = 0; char * dec = 0;
textmodel::gettext (str);
enc = encode_base64 (string::get (str)); dec = decode_base64 (enc);
showmessage ("%s\n\n%s\n\n%d", enc, dec, strcmp (string::get (str), dec));
release (enc); release (dec);
return 0; }
Write the content of the current textmodel base64 encoded to a file. After reading and decoding this files boths strings must be equal. Take care to use a big enoug buffer while reading or read and decoded using a loop.
int main () { String str = string::alloc (); char * enc = 0; char * dec = 0; char buf [3001]; int fi = 0;
textmodel::gettext (str);
// Encode to file enc = encode_base64 (string::get (str));
fi = file::open ("$DESKTOP/txt.txt", "w"); file::write (fi, enc); file::close (fi);
// Decode from file fi = file::open ("$DESKTOP/txt.txt", "r"); file::read (fi, buf, 3000); file::close (fi); dec = decode_base64 (buf);
showmessage ("%s\n\n%s\n\n%d", enc, dec, strcmp (string::get (str), dec));
release (enc); release (dec);
return 0; }
Alphabetic index HTML hierarchy of classes or Java