Base64ToString (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 2: Line 2:


This [[Intrinsic classes|intrinsic]] function returns the unencoded value of a base-64 encoded string.
This [[Intrinsic classes|intrinsic]] function returns the unencoded value of a base-64 encoded string.
                                                                                                     
 
Base64toString is available as of version 7.2 of the [[Sirius Mods]].                                
Base64toString is available as of version 7.2 of the [[Sirius Mods]].
==Syntax==
==Syntax==
{{Template:String:Base64ToString syntax}}
{{Template:String:Base64ToString syntax}}
Line 13: Line 13:
<td>A Base64-encoded string value.</td></tr>
<td>A Base64-encoded string value.</td></tr>
</table>
</table>
                                                                                               
 
===Exceptions===                                                                                    
===Exceptions===
This [[Intrinsic classes|intrinsic]] function can throw the following exceptions:                    
This [[Intrinsic classes|intrinsic]] function can throw the following exceptions:
<dl>                                                                                                
<dl>
<dt>[[InvalidBase64data]]                                                                            
<dt>[[InvalidBase64data]]
<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.                                                                                              
value.
The exception object indicates the position of the first invalid character                          
The exception object indicates the position of the first invalid character
in the method object string.                                                                        
in the method object string.
</dl>                                                                                                
</dl>
==Usage notes==
==Usage notes==
*Base-64 encoding is useful for encoding strings that might contain                                  
*Base-64 encoding is useful for encoding strings that might contain
binary or other characters that could cause problems in certain contexts.                            
binary or other characters that could cause problems in certain contexts.
For example, binary characters can be problematic when sent in e-mail.                              
For example, binary characters can be problematic when sent in e-mail.
                                                                                                     
 
Base-64 encoding is an alternative to hexadecimal encoding.                                          
Base-64 encoding is an alternative to hexadecimal encoding.
Hexadecimal encoding has the advantage that it's simpler, but it has                                
Hexadecimal encoding has the advantage that it's simpler, but it has
the disadvantage that it requires two bytes for every encoded byte.              
the disadvantage that it requires two bytes for every encoded byte.
Base-64 encoding, because it uses more characters (64, as the name would                    
Base-64 encoding, because it uses more characters (64, as the name would
suggest), only requires four bytes for every three encoded bytes.                          
suggest), only requires four bytes for every three encoded bytes.
*A complete explanation of base-64 encoding can be easily found on the                      
*A complete explanation of base-64 encoding can be easily found on the
internet or in many software textbooks.                                                    
internet or in many software textbooks.
*The Base64toString function accepts both the standard base64 encoding                      
*The Base64toString function accepts both the standard base64 encoding
(where the encoded string is padded out to an even multiple of four bytes by                
(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                
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                
equals signs are added and the encoded string might not be an exact multiple
of four bytes).                                                                            
of four bytes).
*The inverse of Base64toString is [[StringToBase64 (String function)|StringToBase64]].
*The inverse of Base64toString is [[StringToBase64 (String function)|StringToBase64]].


==Examples==
==Examples==
                                                                                           
 
The following statement displays ''''Sleeping Bear'''':                                    
The following statement displays ''''Sleeping Bear'''':
     [[Intrinsic classes#printtext|printText]] {'4pOFhZeJlYdAwoWBmQ==':base64toString}
     [[Intrinsic classes#printtext|printText]] {'4pOFhZeJlYdAwoWBmQ==':base64toString}


===See also===                                                                                        
===See also===
[[List of intrinsic String methods]]
[[List of intrinsic String methods]]



Revision as of 14:04, 19 January 2011

Convert a base 64 string to Ebcdic (String class)


This intrinsic function returns the unencoded value of a base-64 encoded string.

Base64toString is available as of version 7.2 of the Sirius Mods.

Syntax

%outString = string:Base64ToString Throws InvalidBase64Data

Syntax terms

%outStr A string variable to receive the unencoded value of the method object string.
string A Base64-encoded string value.

Exceptions

This intrinsic function 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).

Examples

The following statement displays 'Sleeping Bear':

   printText {'4pOFhZeJlYdAwoWBmQ==':base64toString}

See also

List of intrinsic String methods