Utf16ToUnicode (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 25: Line 25:
==Usage notes==
==Usage notes==
<ul><li>The input UTF-16 stream may contain a Byte Order Mark (U+FEFF).<ul><li>If one is present, that controls the conversion from UTF-16 to <var>Unicode</var>.<li> 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>
<ul><li>The input UTF-16 stream may contain a Byte Order Mark (U+FEFF).<ul><li>If one is present, that controls the conversion from UTF-16 to <var>Unicode</var>.<li> 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 <var>Utf16ToUnicode</var> function is available as of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.3.</ul>
<li>The <var>Utf16ToUnicode</var> function is available as of <var class="product">[[Sirius Mods|Sirius Mods]]</var> Version 7.3.</ul>


==Examples==
==Examples==

Revision as of 17:46, 4 May 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 Name-Required, 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.

    %u unicode %u = '0032':X:Utf16ToUnicode print %u

    The result is:

    2

See also