UnicodeToUtf16 (Unicode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (syntax terms, tags and links)
Line 7: Line 7:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%string</th>
<tr><th>%string</th>
<td>A <var>String</var> or <var>Longstring</var> variable to receive the method object string translated to a UTF-16 Big-Endian byte stream (that is, any <var>Unicode</var> point U+wxyz results in the pair of bytes X'wx' and X'yz', in that order). </td></tr>
<td>A <var>String</var> or <var>Longstring</var> variable to receive the method object string translated to a UTF-16 Big-Endian byte stream (that is, any <var>Unicode</var> point <code>U+wxyz</code> results in the pair of bytes <code>X'wx'</code> and <code>X'yz'</code>, in that order). </td></tr>
<tr><th>unicode</th>
<tr><th>unicode</th>
<td>A <var>Unicode</var> string. </td></tr>
<td>A <var>Unicode</var> string. </td></tr>
<tr><th>InsertBOM</th>
<tr><th>InsertBOM</th>
<td>The optional (<var>[[Methods#Named parameters|Name-Required]]</var>) <var class="term">InsertBOM</var> argument is a <var>[[Boolean]]</var>: <ul> <li>If its value is <code>True</code>, the "Byte Order Mark" (U+FEFF) is inserted at the start of the output stream. <li>If its value is <code>False</code>, the default, no Byte Order Mark is inserted. </ul></td></tr>
<td>The optional (<var>[[Methods#Named parameters|NameRequired]]</var>) <var class="term">InsertBOM</var> argument is a <var>[[Boolean]]</var>: <ul> <li>If its value is <code>True</code>, the "Byte Order Mark" (U+FEFF) is inserted at the start of the output stream. <li>If its value is <code>False</code>, the default, no Byte Order Mark is inserted. </ul></td></tr>
</table>
</table>



Revision as of 20:08, 1 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

Examples

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