UnicodeToUtf16 (Unicode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 25: Line 25:


==Examples==
==Examples==
 
<ol><li>
The following fragment shows a successful call of <var>UnicodeToUtf16</var>.
The following fragment shows a successful call of <var>UnicodeToUtf16</var>.
<p class="code">%u unicode initial('&amp;#x31;':[[U (String function)|U]])
<p class="code">%u unicode initial('&amp;#x31;':[[U (String function)|U]])
Line 34: Line 34:
<p class="output">0031
<p class="output">0031
FEFF0031
FEFF0031
</p>
</p></ol>


==See also==
==See also==

Revision as of 00:52, 14 March 2011

Translate to UTF-16 (Unicode class)

UnicodeToUtf16 converts a Unicode string to a UTF-16 Longstring byte stream.

Syntax

%string = unicode:UnicodeToUtf16[( [InsertBOM= boolean])]

Syntax terms

%string A String or Longstring variable to receive the method object string translated to a UTF-16 Big-Endian byte stream (that is, any Unicode point U+wxyz results in the pair of bytes X'wx' and X'yz', in that order).
unicode A Unicode string.
InsertBOM The optional (NameRequired) InsertBOM argument is a Boolean:
  • If its value is True, the "Byte Order Mark" (U+FEFF) is inserted at the start of the output stream.
  • If its value is False, the default, no Byte Order Mark is inserted.

Exceptions

UnicodeToUtf16 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

  • UnicodeToUtf16 is available as of Sirius Mods Version 7.3.

Examples

  1. The following fragment shows a successful call of UnicodeToUtf16.

    %u unicode initial('&#x31;':U) print %u:unicodeToUtf16:stringToHex print %u:unicodeToUtf16(InsertBOM=True):stringToHex

    The result is:

    0031 FEFF0031

See also