Utf16ToUnicode (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (match syntax diagram to revised template and fix tags; still some incomplete / unfound links)
Line 1: Line 1:
{{Template:String:Utf16ToUnicode subtitle}}
{{Template:String:Utf16ToUnicode subtitle}}


This [[Intrinsic classes|intrinsic]] function converts a UTF-16 <var>Longstring</var> byte stream to <var>Unicode</var>.
The <var>Utf16ToUnicode</var> [[Intrinsic classes|intrinsic]] function converts a UTF-16 <var>Longstring</var> byte stream to <var>Unicode</var>.
The <var>Utf16ToUnicode</var> function is available as of version 7.3 of the <var class=product>Sirius Mods</var>.
 
==Syntax==
==Syntax==
{{Template:String:Utf16ToUnicode syntax}}
{{Template:String:Utf16ToUnicode syntax}}
Line 8: Line 8:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%unicode</th>
<tr><th>%unicode</th>
<td>A string variable to receive the method object string translated to <var>Unicode</var>. </td></tr>
<td>A string variable to receive the method object <var class="term">string</var> translated to <var>Unicode</var>. </td></tr>
<tr><th>string</th>
<tr><th>string</th>
<td>A <var>String</var> or <var>Longstring</var> that is presumed to contain a UTF-16 byte stream.</td></tr>
<td>A string that is presumed to contain a UTF-16 byte stream.</td></tr>
<tr><th>AllowUntranslatable</th>
<td><var class="term">AllowUntranslatable</var> is an optional, but <var class="term">nameRequired</var>, parameter, which is a <var>[[Boolean Enumeration]]</var> value that specifies ....</td></tr>
<tr><th>Bom</th>
<td></td></tr>
</table>
</table>


===Exceptions===
===Exceptions===
This [[Intrinsic classes|intrinsic]] function can throw the following exception:
<var>Utf16ToUnicode</var> can throw the following exception:
<dl>
<dl>
<dt>[[CharacterTranslationException]]
<dt><var>[[CharacterTranslationException_class|CharacterTranslationException]]</var>
<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 <var>Unicode</var>. 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.
<ul><li>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 <var>Unicode</var>. 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.
<li>The <var>Utf16ToUnicode</var> function is available as of <var class="product">Sirius Mods</var> Version 7.3.</ul>
*The [[Utf8ToUnicode (String function)|Utf8ToUnicode]] method converts a UTF-8 byte stream to <var>Unicode</var>.
 
==Examples==
==Examples==
 
<ol><li>In the following fragment, <var>Utf16ToUnicode</var> converts a hexadecimal input to a single <var>Unicode</var> character. The <var>[[X (String function)|X]]</var> constant function is used in the example.
In the following fragment, <var>Utf16ToUnicode</var> converts a hexadecimal input to a single <var>Unicode</var> character. The ''''[[X (String function)|X]]'''' constant function is used in the example.
<p class="code">%u <var>Unicode</var>
<p class="code">%u <var>Unicode</var>
%u = '0032':X:<var>Utf16ToUnicode</var>
%u = '0032':X:Utf16ToUnicode
Print %u
Print %u
</p>
</p>
The result is:
The result is:
<p class="output">2
<p class="output">2
</p></ol>


</p>
==See also==
==See also==
<ul><li>[[Unicode#UTF-8_and_UTF-16|UTF-8 and UTF-16]] has more information about UTF-16 conversions.
<li>The [[Utf8ToUnicode (String function)|Utf8ToUnicode]] method converts a UTF-8 byte stream to <var>Unicode</var>.</ul>
{{Template:String:Utf16ToUnicode footer}}
{{Template:String:Utf16ToUnicode footer}}

Revision as of 23:16, 2 February 2011

Convert a UTF-16 Longstring bytestream to Unicode (String class)


The Utf16ToUnicode intrinsic function converts a UTF-16 Longstring byte stream to Unicode.

Syntax

%unicode = string:Utf16ToUnicode[( [AllowUntranslatable= boolean], - [Bom= utf16BOM])] Throws CharacterTranslationException

Syntax terms

%unicode A string variable to receive the method object string translated to Unicode.
string A string that is presumed to contain a UTF-16 byte stream.
AllowUntranslatable AllowUntranslatable is an optional, but nameRequired, parameter, which is a Boolean Enumeration value that specifies ....
Bom

Exceptions

Utf16ToUnicode 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.
  • The Utf16ToUnicode function is available as of Sirius Mods Version 7.3.

Examples

  1. 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

See also