UnicodeToUtf16 (Unicode function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (1 revision) |
||
Line 27: | Line 27: | ||
<ol><li> | <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('& | <p class="code">%u unicode initial('&#x31;':[[U (String function)|U]]) | ||
print %u:unicodeToUtf16:[[StringToHex (String function)|stringToHex]] | print %u:unicodeToUtf16:[[StringToHex (String function)|stringToHex]] | ||
print %u:unicodeToUtf16(InsertBOM=True):stringToHex | print %u:unicodeToUtf16(InsertBOM=True):stringToHex |
Revision as of 17:32, 6 November 2012
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:
|
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
-
The following fragment shows a successful call of UnicodeToUtf16.
%u unicode initial('1':U) print %u:unicodeToUtf16:stringToHex print %u:unicodeToUtf16(InsertBOM=True):stringToHex
The result is:
0031 FEFF0031
See also
- For more information about UTF-16 conversions, see "Unicode: UTF-8 and UTF-16".
- UnicodeToUtf8 converts a Unicode string to UTF-8.
- Utf16ToUnicode converts a UTF-16 Longstring byte stream to Unicode.