Base64ToString (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
 
(34 intermediate revisions by 7 users not shown)
Line 1: Line 1:
This [[Intrinsic classes|intrinsic]] function returns the unencoded value of a base-64 encoded string.
{{Template:String:Base64ToString subtitle}}
                                                                                                     
Base64toString is available as of version 7.2 of the [[Sirius Mods]].                               
===Base64toString syntax===                                                                         
  %outStr = string:base64toString                                                                   
===Syntax Terms===                                                                                   
<dl>                                                                                                 
<dt>%outStr                                                                                         
<dd>A string variable to receive the unencoded value of the                                         
method object string.                                                                               
<dt>string                                                                                           
<dd>A Base64-encoded string value.                                                                   
</dl>                                                                                               
===Exceptions===                                                                                     
This [[Intrinsic classes|intrinsic]] function can throw the following exceptions:                    
<dl>                                                                                                 
<dt>[[InvalidBase64data]]                                                                           
<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.                                                                         
</dl>                                                                                               
===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).                                                                             
*The inverse of Base64toString is [[StringToBase64 (String function)|StringToBase64]].


===Examples===                                                                              
==Syntax==
                                                                                           
{{Template:String:Base64ToString syntax}}
The following statement displays ''''Sleeping Bear'''':                                     
===Syntax terms===
    [[PrintText statement|printText]] {'4pOFhZeJlYdAwoWBmQ==':base64toString}
<table class="syntaxTable">
<tr><th>%outString</th>
<td>A string variable to receive the unencoded value of the method object <var class="term">string</var>.</td></tr>
<tr><th>string</th>
<td>The input, base64-encoded string value.</td></tr>
</table>


===See also===                                                                                       
==Exceptions==
[[List of Intrinsic String Methods]]
<var>Base64ToString</var> can throw the following exceptions:
<dl>
<dt><var>[[InvalidBase64Data class|InvalidBase64data]]</var>
<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.
</dl>


==Usage notes==
<ul><li>Base64 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.<li>Base64 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. Base64 encoding, because it uses more characters (64, as the name would suggest), only requires four bytes for every three encoded bytes.
<li>A complete explanation of base64 encoding can be easily found on the internet or in many software textbooks.
<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 equal signs) and a non-standard encoding (where no trailing equal 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.
</ul>


[[Category:Intrinsic String methods|Base64toString function]]
==Examples==
[[Category:Intrinsic methods]]
The following statement displays <code>Sleeping Bear</code>:
[[Category:System methods]]
<p class="code">[[PrintText statement|printText]] {'4pOFhZeJlYdAwoWBmQ==':base64toString}
</p>
 
==See also==
<ul><li>The inverse of <var>Base64ToString</var> is <var>[[StringToBase64 (String function)|StringToBase64]]</var>.</ul>
{{Template:String:Base64ToString footer}}

Latest revision as of 18:35, 2 November 2012

Convert a base 64 string to Ebcdic (String class)


Syntax

%outString = string:Base64ToString Throws InvalidBase64Data

Syntax terms

%outString A string variable to receive the unencoded value of the method object string.
string The input, 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

  • Base64 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.
  • Base64 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. Base64 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 base64 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 equal signs) and a non-standard encoding (where no trailing equal 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