Base64ToString (String function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (first pass, match syntax diagram to template and fix tags) |
||
Line 1: | Line 1: | ||
{{Template:String:Base64ToString subtitle}} | {{Template:String:Base64ToString subtitle}} | ||
<var>Base64ToString</var> is and [[Intrinsic classes|intrinsic]] function returns the unencoded value of a base-64 encoded string. | |||
==Syntax== | ==Syntax== | ||
{{Template:String:Base64ToString syntax}} | {{Template:String:Base64ToString syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%string</th> | ||
<td>A string variable to receive the unencoded value of the | <td>A string variable to receive the unencoded value of the method object <var class="term">string</var>.</td></tr> | ||
<tr><th>string</th> | <tr><th><var class="term">string</var></th> | ||
<td>A Base64-encoded string value.</td></tr> | <td>A Base64-encoded string value.</td></tr> | ||
</table> | </table> | ||
==Exceptions== | |||
<var>Base64ToString</var> can throw the following exceptions: | |||
<dl> | <dl> | ||
<dt>[[InvalidBase64data]] | <dt><var>[[InvalidBase64Data class|InvalidBase64data]]</var> | ||
<dd>If the method object string does not contain a properly encoded base64 | <dd>If the method object string does not contain a properly encoded base64 value. The exception object indicates the position of the first invalid character in the method object string. | ||
value. | |||
The exception object indicates the position of the first invalid character | |||
in the method object string. | |||
</dl> | </dl> | ||
==Usage notes== | ==Usage notes== | ||
<ul><li>Base-64 encoding is useful for encoding strings that might contain binary or other characters that could cause problems in certain contexts. For example, binary characters can be problematic when sent in e-mail.<p>Base-64 encoding is an alternative to hexadecimal encoding. Hexadecimal encoding has the advantage that it's simpler, but it has the disadvantage that it requires two bytes for every encoded byte. Base-64 encoding, because it uses more characters (64, as the name would suggest), only requires four bytes for every three encoded bytes.</p> | |||
binary or other characters that could cause problems in certain contexts. | <li>A complete explanation of base-64 encoding can be easily found on the internet or in many software textbooks. | ||
For example, binary characters can be problematic when sent in e-mail. | <li>The <var>Base64ToString</var> function accepts both the standard base64 encoding (where the encoded string is padded out to an even multiple of four bytes by adding trailing equals signs) and a non-standard encoding (where no trailing equals signs are added and the encoded string might not be an exact multiple of four bytes). | ||
<li><var>Base64ToString</var> is available as of <var class="product">Sirius Mods</var> version 7.2. | |||
Base-64 encoding is an alternative to hexadecimal encoding. | </ul> | ||
Hexadecimal encoding has the advantage that it's simpler, but it has | |||
the disadvantage that it requires two bytes for every encoded byte. | |||
Base-64 encoding, because it uses more characters (64, as the name would | |||
suggest), only requires four bytes for every three encoded bytes. | |||
internet or in many software textbooks. | |||
(where the encoded string is padded out to an even multiple of four bytes by | |||
adding trailing equals signs) and a non-standard encoding (where no trailing | |||
equals signs are added and the encoded string might not be an exact multiple | |||
of four bytes). | |||
==Examples== | ==Examples== | ||
<ol><li>The following statement displays ''''Sleeping Bear'''': | |||
The following statement displays ''''Sleeping Bear'''': | |||
<p class="code">[[Intrinsic classes#printtext|printText]] {'4pOFhZeJlYdAwoWBmQ==':base64toString} | <p class="code">[[Intrinsic classes#printtext|printText]] {'4pOFhZeJlYdAwoWBmQ==':base64toString} | ||
</p></ol> | |||
==See also== | ==See also== | ||
<ul><li>The inverse of <var>Base64ToString</var> is <var>[[StringToBase64 (String function)|StringToBase64]]</var>.</ul> | |||
{{Template:String:Base64ToString footer}} | {{Template:String:Base64ToString footer}} |
Revision as of 03:24, 31 January 2011
Convert a base 64 string to Ebcdic (String class)
Base64ToString is and intrinsic function returns the unencoded value of a base-64 encoded string.
Syntax
%outString = string:Base64ToString Throws InvalidBase64Data
Syntax terms
%string | A string variable to receive the unencoded value of the method object string. |
---|---|
string | A Base64-encoded string value. |
Exceptions
Base64ToString can throw the following exceptions:
- InvalidBase64data
- If the method object string does not contain a properly encoded base64 value. The exception object indicates the position of the first invalid character in the method object string.
Usage notes
- Base-64 encoding is useful for encoding strings that might contain binary or other characters that could cause problems in certain contexts. For example, binary characters can be problematic when sent in e-mail.
Base-64 encoding is an alternative to hexadecimal encoding. Hexadecimal encoding has the advantage that it's simpler, but it has the disadvantage that it requires two bytes for every encoded byte. Base-64 encoding, because it uses more characters (64, as the name would suggest), only requires four bytes for every three encoded bytes.
- A complete explanation of base-64 encoding can be easily found on the internet or in many software textbooks.
- The Base64ToString function accepts both the standard base64 encoding (where the encoded string is padded out to an even multiple of four bytes by adding trailing equals signs) and a non-standard encoding (where no trailing equals signs are added and the encoded string might not be an exact multiple of four bytes).
- Base64ToString is available as of Sirius Mods version 7.2.
Examples
- The following statement displays 'Sleeping Bear':
printText {'4pOFhZeJlYdAwoWBmQ==':base64toString}
See also
- The inverse of Base64ToString is StringToBase64.