Utf8ToUnicode (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (bad closing tage)
m (more tags)
Line 1: Line 1:
{{Template:String:Utf8ToUnicode subtitle}}
{{Template:String:Utf8ToUnicode subtitle}}
The <var>Utf8ToUnicode</var> [[Intrinsic classes|intrinsic]] function converts a UTF-8 string to <var>Unicode</var>.
The <var>Utf8ToUnicode</var> [[Intrinsic classes|intrinsic]] function converts a UTF-8 string to <var>Unicode</var>.


Line 24: Line 23:


==Usage notes==
==Usage notes==
<ul><li><var>Utf8ToUnicode</var> is available as of <var class="product">[[Sirius Mods]]</var> Version 7.3.</ul>
<ul><li><var>Utf8ToUnicode</var> is available as of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.3.</ul>


==Examples==
==Examples==
<ol><li>
<ol><li>
In the following fragment, <var>Utf8ToUnicode</var> converts a hexadecimal input to a single <var>Unicode</var> character. In case the <var>Unicode</var> character translates to an EBCDIC character that cannot be displayed, the CharacterEncode option of <var>[[UnicodeToEbcdic (Unicode function)|UnicodeToEbcdic]]</var> causes the output of a hexadecimal character reference. The <var>[[X (String function)|X]]</var> constant function is used in the example.
In the following fragment, <var>Utf8ToUnicode</var> converts a hexadecimal input to a single <var>Unicode</var> character. In case the <var>Unicode</var> character translates to an EBCDIC character that cannot be displayed, the CharacterEncode option of <var>[[UnicodeToEbcdic (Unicode function)|UnicodeToEbcdic]]</var> causes the output of a hexadecimal character reference.
<p class="code">%u unicode
<p class="code">%u unicode
%u = 'E284A2':X:Utf8ToUnicode
%u = 'E284A2':[[X (String function)|X]]:Utf8ToUnicode
Print %u:unicodeToEbcdic(CharacterEncode=true)
print %u:unicodeToEbcdic(CharacterEncode=true)
</p>
</p>
The result of the above fragment is the character reference for the trademark character:
The result of the above fragment is the character reference for the trademark character:

Revision as of 06:23, 25 February 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 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

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

Examples

  1. 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