_BASE64DECODE$

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search

The _BASE64DECODE$ function decodes a Base64-encoded string back to its original binary or textual representation.


Syntax

decodedString$ = _BASE64DECODE$(stringToDecode$)


Parameters

  • stringToDecode$ is the Base64-encoded string to be decoded. It must conform to the Base64 encoding standard.


Description

  • The _BASE64DECODE$ function takes a Base64-encoded string as input and returns the decoded data as a string.
  • If the input string is invalid or improperly formatted for Base64, the function will return an empty string.
  • It is commonly used for decoding strings that were previously encoded with _BASE64ENCODE$.
  • The decoded string may contain binary data, so ensure the target string variable can handle such content if necessary.


Availability


Examples

Example 1
Decoding a Base64 string.
CONST encodedString = _
    "VGhvJyBtdWNoIGlzIHRha2VuLCBtdWNoIGFiaWRlczsgYW5kIHRobycNCldlIGFyZSBub3Qgbm9" + _
    "3IHRoYXQgc3RyZW5ndGggd2hpY2ggaW4gb2xkIGRheXMNCk1vdmVkIGVhcnRoIGFuZCBoZWF2ZW" + _
    "47IHRoYXQgd2hpY2ggd2UgYXJlLCB3ZSBhcmU7DQpPbmUgZXF1YWwgdGVtcGVyIG9mIGhlcm9pY" + _
    "yBoZWFydHMsDQpNYWRlIHdlYWsgYnkgdGltZSBhbmQgZmF0ZSwgYnV0IHN0cm9uZyBpbiB3aWxs" + _
    "DQpUbyBzdHJpdmUsIHRvIHNlZWssIHRvIGZpbmQsIGFuZCBub3QgdG8geWllbGQu"

PRINT "Decoded string: "; _BASE64DECODE$(encodedString)
Decoded string:
Tho' much is taken, much abides; and tho'

We are not now that strength which in old days

Moved earth and heaven; that which we are, we are;

One equal temper of heroic hearts,

Made weak by time and fate, but strong in will

To strive, to seek, to find, and not to yield.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link