$Lstr Base64 Decode: Difference between revisions
(→Syntax) |
m (→Syntax) |
||
Line 18: | Line 18: | ||
<p>%DECODED is set to the base 64 decoding of <var class="term">string</var>.</p> | <p>%DECODED is set to the base 64 decoding of <var class="term">string</var>.</p> | ||
==Usage notes== | |||
<ul> | |||
<li>You can check for an invalid base 64 encoding by checking for the null string return value from $Lstr_Base64_Decode. Of course, if it is possible that the argument is null, the null string is a valid returned value. If you need to check for errors, and the null string is a possible argument value, you can use an approach such as the following: | |||
<p class="code"> % | <p class="code">%STR = $Lstr_Base64_Decode(%IN) | ||
IF %STR EQ '' | |||
IF %IN NE '' THEN | |||
error code ... | |||
END IF | |||
END IF | |||
</p> | </p> | ||
<li><var>[[$Lstr_Base64_Encode]]</var> is the inverse of $Lstr_Base64_Decode. | |||
</ul> | |||
==Example== | |||
Given the following argument of length 4: | |||
<p class="code"> % | <p class="code">%JUNK = $Lstr_Base64_Decode('ABCD') | ||
</p> | </p> | ||
%JUNK is set to the byte string (of length 3) represented in hexadecimal as X'001083'. | |||
==Products authorizing {{PAGENAMEE}}== | ==Products authorizing {{PAGENAMEE}}== |
Revision as of 23:31, 15 April 2013
Convert from base 64 to byte string
Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Lstr_Base64_Decode function is the Base64ToString (String function).
This function converts from a base 64 encoded string to the decoded byte string. It is identical to $Base64_Decode, except it is longstring capable.
The $Lstr_Base64_Decode function accepts one argument and returns a string result whose base 64 encoding is that argument.
The first argument is a longstring which is a base 64 encoding.
The returned value is the base 64 decoding of the argument string. If the argument is not a valid base 64 encoding, the null string is returned.
Syntax
%DECODED = $Lstr_Base64_Decode(string)
%DECODED is set to the base 64 decoding of string.
Usage notes
- You can check for an invalid base 64 encoding by checking for the null string return value from $Lstr_Base64_Decode. Of course, if it is possible that the argument is null, the null string is a valid returned value. If you need to check for errors, and the null string is a possible argument value, you can use an approach such as the following:
%STR = $Lstr_Base64_Decode(%IN) IF %STR EQ IF %IN NE THEN error code ... END IF END IF
- $Lstr_Base64_Encode is the inverse of $Lstr_Base64_Decode.
Example
Given the following argument of length 4:
%JUNK = $Lstr_Base64_Decode('ABCD')
%JUNK is set to the byte string (of length 3) represented in hexadecimal as X'001083'.