Utf8ToUnicode (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 15: Line 15:


==Exceptions==
==Exceptions==
<var>Utf8ToUnicode</var> can throw the following exception:
<dl>
<dt><var>[[CharacterTranslationException_class|CharacterTranslationException]]</var>
<dd>If the method encounters a translation problem, properties of the exception object may indicate the location and type of problem.
</dl>
<var>Utf8ToUnicode</var> can throw the following exception:
<table style="border:none;  background-color: transparent;">
<tr><th style="border: none">[[CharacterTranslationException_class|CharacterTranslationException]] </th>
<td style="border: none">If the method encounters a translation problem, properties of the exception object may indicate the location and type of problem. </td></tr>
</table>


<var>Utf8ToUnicode</var> can throw the following exception:
<var>Utf8ToUnicode</var> can throw the following exception:

Revision as of 23:39, 21 November 2011

Convert a UTF-8 Longstring bytestream to Unicode (String class)

The Utf8ToUnicode intrinsic function converts a UTF-8 string to Unicode.

Syntax

%unicode = string:Utf8ToUnicode[( [AllowUntranslatable= boolean])] Throws CharacterTranslationException

Syntax terms

%unicode A Unicode string variable to receive the method object string translated to Unicode.
string The method object string that is presumed to contain a UTF-8 byte stream.
AllowUntranslatable This argument is usable only by Sirius Software.

Exceptions

Utf8ToUnicode 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

  • Utf8ToUnicode is available as of Sirius Mods Version 7.3.

Examples

In the following fragment, Utf8ToUnicode converts a hexadecimal input to a single Unicode character. In case the Unicode character translates to an EBCDIC character that cannot be displayed, the CharacterEncode option of UnicodeToEbcdic causes the output of a hexadecimal character reference.

%u unicode %u = 'E284A2':X:Utf8ToUnicode print %u:unicodeToEbcdic(CharacterEncode=true)

The result of the above fragment is the character reference for the trademark character:

&#x2122;

See also