Utf16ToUnicode (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
This [[Intrinsic Classes|intrinsic]] function converts a UTF-16 Longstring byte stream to Unicode.    
This [[Intrinsic Classes|intrinsic]] function converts a UTF-16 Longstring byte stream to Unicode.  
                                                                                                       
The Utf16ToUnicode function is available as of version 7.3 of the [[Sirius Mods]].    
The Utf16ToUnicode function is available as of version 7.3 of the [[Sirius Mods]].                    
===Utf16ToUnicode syntax===  
===Utf16ToUnicode syntax===                                                                            
   %unicode = string:Utf16ToUnicode      
   %unicode = string:Utf16ToUnicode                                                                    
===Syntax Terms===
===Syntax Terms===                                                                                    
<dl>                                                                                                     
<dl>                                                                                                     
<dt>%unicode                                                                                             
<dt>%unicode                                                                                             
<dd>A string variable to receive the method object string translated to Unicode.                      
<dd>A string variable to receive the method object string translated to Unicode.
<dt>string                                                                                               
<dt>string                                                                                               
<dd>A String or Longstring that is presumed to contain a UTF-16 byte stream.                          
<dd>A String or Longstring that is presumed to contain a UTF-16 byte stream.  
                                                                                                          
                                                                                                          
</dl>                                                                                                   
</dl>                                                                                                   
===Exceptions===                                                                                         
===Exceptions===                                                                                         
                                                                                                       
This [[Intrinsic Classes|intrinsic]] function can throw the following exception:  
This [[Intrinsic Classes|intrinsic]] function can throw the following exception:                      
<dl>                                                                                                     
<dl>                                                                                                     
<dt>[[CharacterTranslationException]]                                                                   
<dt>[[CharacterTranslationException]]                                                                   
<dd>If the method encounters a translation problem,                                                    
<dd>If the method encounters a translation problem,
properties of the exception object may indicate the location and type of problem.                      
properties of the exception object may indicate the location and type of problem.
</dl>                                                                                                   
</dl>                                                                                                   
===Usage Notes===                                                                                      
===Usage Notes===                            
*The input UTF-16 stream may contain a Byte Order Mark (U+FEFF). If one is present, that controls the conversion from UTF-16 to Unicode. If a Byte Order Mark is not present, the input stream is considered to be a Big Endian stream, that is, it is the same as if the stream were preceded by the two bytes X'FE' and X'FF', in that order.  
*The input UTF-16 stream may contain a Byte Order Mark (U+FEFF). If one is present, that controls the conversion from UTF-16 to Unicode. If a Byte Order Mark is not present, the input stream is considered to be a Big Endian stream, that is, it is the same as if the stream were preceded by the two bytes X'FE' and X'FF', in that order.  
*[[UTF-8 and UTF-16]] has more information about UTF-16 conversions.                                  
*[[UTF-8 and UTF-16]] has more information about UTF-16 conversions.    
*The [[Intrinsic Utf8ToUnicode Function|Utf8ToUnicode]] method converts a UTF-8 byte stream to Unicode.  
*The [[Utf8ToUnicode (String function)|Utf8ToUnicode]] method converts a UTF-8 byte stream to Unicode.  
===Examples===  
===Examples===  
                
                
In the following fragment, Utf16ToUnicode converts a hexadecimal input to a single Unicode character. The ''''[[Intrinsic X Function|X]]'''' constant function is used in the example.     
In the following fragment, Utf16ToUnicode converts a hexadecimal input to a single Unicode character. The ''''[[X (String function)|X]]'''' constant function is used in the example.     
     %u Unicode                                                                                       
     %u Unicode                                                                                       
     %u = '0032':X:Utf16ToUnicode                                                                     
     %u = '0032':X:Utf16ToUnicode                                                                     

Revision as of 22:52, 21 October 2010

This intrinsic function converts a UTF-16 Longstring byte stream to Unicode. The Utf16ToUnicode function is available as of version 7.3 of the Sirius Mods.

Utf16ToUnicode syntax

  %unicode = string:Utf16ToUnicode       

Syntax Terms

%unicode
A string variable to receive the method object string translated to Unicode.
string
A String or Longstring that is presumed to contain a UTF-16 byte stream.

Exceptions

This intrinsic function can throw the following exception:

CharacterTranslationException
If the method encounters a translation problem, properties of the exception object may indicate the location and type of problem.

Usage Notes

  • The input UTF-16 stream may contain a Byte Order Mark (U+FEFF). If one is present, that controls the conversion from UTF-16 to Unicode. If a Byte Order Mark is not present, the input stream is considered to be a Big Endian stream, that is, it is the same as if the stream were preceded by the two bytes X'FE' and X'FF', in that order.
  • UTF-8 and UTF-16 has more information about UTF-16 conversions.
  • The Utf8ToUnicode method converts a UTF-8 byte stream to Unicode.

Examples

In the following fragment, Utf16ToUnicode converts a hexadecimal input to a single Unicode character. The 'X' constant function is used in the example.

   %u Unicode                                                                                       
   %u = '0032':X:Utf16ToUnicode                                                                     
   Print %u                                                                                         

The result is:

   2