Utf8ToUnicode (String function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (1 revision) |
||
Line 11: | Line 11: | ||
<td>The method object <var class="term">string</var> that is presumed to contain a UTF-8 byte stream.</td></tr> | <td>The method object <var class="term">string</var> that is presumed to contain a UTF-8 byte stream.</td></tr> | ||
<tr><th><var>AllowUntranslatable</var></th> | <tr><th><var>AllowUntranslatable</var></th> | ||
<td><var>AllowUntranslatable</var> is an optional, but <var>[[Methods#Named parameters| | <td><var>AllowUntranslatable</var> is an optional, but <var>[[Methods#Named parameters|name required]]</var>, parameter, which is a <var>[[Boolean Enumeration]]</var> value that specifies ....</td></tr> | ||
</table> | </table> | ||
Line 33: | Line 33: | ||
</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;amp;#x2122; | <p class="output">&amp;amp;amp;#x2122; | ||
</p></ol> | </p></ol> | ||
Revision as of 19:38, 4 May 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 | AllowUntranslatable is an optional, but name required, parameter, which is a Boolean Enumeration value that specifies .... |
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:
&amp;amp;#x2122;
See also
- Utf8 and Utf16 has more information about UTF-8 conversions.
- UnicodeToUtf8 converts a Unicode string to a UTF-8 Longstring byte stream.
- Utf16ToUnicode converts a UTF-16 byte stream to Unicode.