Utf8ToUnicode (String function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (match syntax diagram to revised template; fix tags and links)
Line 1: Line 1:
{{Template:String:Utf8ToUnicode subtitle}}
{{Template:String:Utf8ToUnicode subtitle}}


This [[Intrinsic classes|intrinsic]] function converts a UTF-8 <var>Longstring</var> byte stream to <var>Unicode</var>.
The <var>Utf8ToUnicode</var> [[Intrinsic classes|intrinsic]] function converts a UTF-8 string to <var>Unicode</var>.


The <var>Utf8ToUnicode</var> function is available as of version 7.3 of the <var class=product>Sirius Mods</var>.
==Syntax==
==Syntax==
{{Template:String:Utf8ToUnicode syntax}}
{{Template:String:Utf8ToUnicode syntax}}
Line 9: Line 8:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%unicode</th>
<tr><th>%unicode</th>
<td>A string variable to receive the method object string translated to <var>Unicode</var>. </td></tr>
<td>A string variable to receive the method object <var class="term">string</var> translated to <var>Unicode</var>.</td></tr>
<tr><th>string</th>
<tr><th>string</th>
<td>A <var>String</var> or <var>Longstring</var> that is presumed to contain a UTF-8 byte stream.</td></tr>
<td>The method object <var>string</var> that is presumed to contain a UTF-8 byte stream.</td></tr>
<tr><th>AllowUntranslatable</th>
<td><i>needs to be written by a real guru</i></td>
</table>
</table>


===Exceptions===
==Exceptions==


This [[Intrinsic classes|intrinsic]] function can throw the following exception:
<var>Utf8ToUnicode</var> can throw the following exception:
<dl>
<dl>
<dt>[[CharacterTranslationException]]
<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.
<dd>If the method encounters a translation problem, properties of the exception object may indicate the location and type of problem.
</dl>
</dl>
==Usage notes==
==Usage notes==
*[[Utf8 and Utf16]] has more information about UTF-8 conversions.
<ul><li><var>Utf8ToUnicode</var> is available as of <var class="product">[[Sirius Mods]]</var> Version 7.3.</ul>
*The [[Utf16ToUnicode (String function)|Utf16ToUnicode]] method converts a UTF-16 byte stream to <var>Unicode</var>.
 
*The [[UnicodeToUtf8 (String function)|UnicodeToUtf8]] method converts a <var>Unicode</var> string to a UTF-8 <var>Longstring</var> byte stream.
==Examples==
==Examples==
 
<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 the [[UnicodeToEbcdic (Unicode function)|UnicodeToEbcdic]] method
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.
causes the output of a hexadecimal character reference. The ''''[[X (String function)|X]]'''' constant function is used in the example.
<p class="code">%u unicode
<p class="output">%u <var>Unicode</var>
%u = 'E284A2':X:Utf8ToUnicode
%u = 'E284A2':X:<var>Utf8ToUnicode</var>
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:
<p class="output">&amp;#x2122;
<p class="output">&amp;#x2122;
</p>
</p></ol>
 
==See also==
==See also==
<ul><li><var>[[Unicode#UTF-8_and_UTF-16|Utf8 and Utf16]]</var> has more information about UTF-8 conversions.
<li><var>[[UnicodeToUtf8_(Unicode_function)|UnicodeToUtf8]]</var> converts a <var>Unicode</var> string to a UTF-8 <var>Longstring</var> byte stream.
<li><var>[[Utf16ToUnicode (String function)|Utf16ToUnicode]] converts a UTF-16 byte stream to <var>Unicode</var>.
</ul>
{{Template:String:Utf8ToUnicode footer}}
{{Template:String:Utf8ToUnicode footer}}

Revision as of 05:32, 3 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 needs to be written by a real guru

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

  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. The X constant function is used in the example.

    %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