Utf16ToUnicode (String function): Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
{{Template:String:Utf16ToUnicode syntax}} | {{Template:String:Utf16ToUnicode syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%unicode</th> | <tr><th>%unicode</th> | ||
<td>A Unicode string variable to receive the method object <var class="term">string</var> translated to <var>Unicode</var>. </td></tr> | <td>A Unicode 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 string 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><var>AllowUntranslatable</var></th> | <tr><th><var>AllowUntranslatable</var></th> | ||
<td>This argument is usable only by | <td>This argument is <i><b>usable only by Rocket Software</b>. [[Contacting Rocket Software Technical Support|Contact Rocket Software]] if you think this argument may be of value to you. | ||
<p> | |||
<var>AllowUntranslatable</var> is a [[Notation conventions for methods#Named arguments|name required]] parameter with a value that is a <var>Boolean</var> enumeration. </p></i></td></tr> | |||
<tr><th><var>BOM</var></th> | <tr><th><var>BOM</var></th> | ||
<td>This argument is usable only by | <td>This Byte Order Mark argument is <i><b>usable only by Rocket Software</b>. Contact Rocket Software if you think this argument may be of value to you.</i> | ||
<p> | |||
<var>BOM</var> is a name required parameter with a value that is a <var>Utf16Bom</var> enumeration. </p></td></tr> | |||
</table> | </table> |
Revision as of 18:21, 23 July 2014
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 Unicode 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 | This argument is usable only by Rocket Software. Contact Rocket Software if you think this argument may be of value to you.
AllowUntranslatable is a name required parameter with a value that is a Boolean enumeration. |
BOM | This Byte Order Mark argument is usable only by Rocket Software. Contact Rocket Software if you think this argument may be of value to you.
BOM is a name required parameter with a value that is a Utf16Bom enumeration. |
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
In the following fragment, Utf16ToUnicode converts a hexadecimal input to a single Unicode character:
%u unicode %u = '0032':X:Utf16ToUnicode print %u
The result is:
2
See also
- UTF-8 and UTF-16 has more information about UTF-16 conversions.
- The Utf8ToUnicode method converts a UTF-8 byte stream to Unicode.