EbcdicToUnicode (String function): Difference between revisions
m (re-match syntax diagram to revised template; fix tags. Still some link targets that need to be found / written.) |
m (→See also) |
||
Line 68: | Line 68: | ||
<p class="code">http://www.w3.org/TR/xhtml1/dtds.html#h-A2 | <p class="code">http://www.w3.org/TR/xhtml1/dtds.html#h-A2 | ||
</p> | </p> | ||
<li>More information is available about <var>[[ | <li>More information is available about <var>[[Unicode]]</var>. | ||
<li>The <var>[[EbcdicToAscii (String function)|EbcdicToAscii]]</var> method converts an EBCDIC string to ASCII.</ul> | <li>The <var>[[EbcdicToAscii (String function)|EbcdicToAscii]]</var> method converts an EBCDIC string to ASCII.</ul> | ||
{{Template:String:EbcdicToUnicode footer}} | {{Template:String:EbcdicToUnicode footer}} |
Revision as of 23:21, 3 February 2011
Convert EBCDIC string to Unicode (String class)
EbcdicToUnicode is an intrinsic function that converts an EBCDIC string to Unicode using the current Unicode tables. Options are available to control:
- the conversion of XML style hexadecimal character references, XHTML entity references, and '&' references are converted to the represented Unicode character;
- how to handle untranslatable EBCDIC characters
Syntax
%unicode = string:EbcdicToUnicode[( [CharacterDecode= boolean], - [Untranslatable= unicode])] Throws CharacterTranslationException
Syntax terms
%unicode | A string variable to receive the method object string translated to Unicode. |
---|---|
string | An EBCDIC character string. |
CharacterDecode | The optional, but nameRequired, argument CharacterDecode is a Boolean enumeration:
|
Untranslatable | The optional, but nameRequired, argument Untranslatable is a single character or a null string that specifies how to handle EBCDIC input characters that are not translatable to Unicode:
The Untranslatable parameter is available as of Sirius Mods version 7.5. It provides the functionality formerly provided by the EbcdicTranslateNonUnicode and the EbcdicRemoveNonUnicode methods, which are invalid as of Sirius Mods 7.5. |
Exceptions
EbcdicToUnicode 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
- Using EbcdicToUnicode (or the U function) is necessary if the string you want to convert to Unicode may contain a hexadecimal character reference. Such a reference cannot be meaningfully assigned to a Unicode variable otherwise.
- EbcdicToUnicode is available as of Sirius Modsversion 7.3.
Examples
- The following fragment shows four calls of EbcdicToUnicode: respectively against translatable EBCDIC characters, a string with a character reference, a string with an entity reference, and a string with an EBCDIC character that cannot be translated to Unicode. The X constant function is used in the example.
%e string Len 20 %u unicode %e = '12' %u = %e:EbcdicToUnicode Print %u Print %u:UnicodeToUtf16:StringToHex %e = '1™2' %u = %e:EbcdicToUnicode(CharacterDecode=True) Print %u:UnicodeToUtf16:StringToHex %e = '©' %u = %e:EbcdicToUnicode(CharacterDecode=True) Print %u %e = 'F1FFF2':X %u = %e:EbcdicToUnicode
The result of the above fragment is:
12 00310032 003121220032 © CANCELLING REQUEST: MSIR.0751: Class STRING, function EBCDICTOUNICODE: CHARACTER TRANSLATIONEXCEPTION exception: EBCDIC character X'FF' without valid translation to Unicode at byte position 2 ...
Note: The initial
Print %u
statement in the example above is not very revealing because it is equivalent to specifyingPrint %u:UnicodeToEbcdic'—'
; a Unicode string is implicitly converted to EBCDIC when it is used in an EBCDIC context like a Print statement. UnicodeToUtf16, however, converts the Unicode variable to a byte-stream string, which StringToHex converts to its hex representation.
See also
- U is a compile-time-only equivalent of the EbcdicToUnicode method (with CharacterDecode argument implicitly set to
True
). - You can find the list of XHTML entities on the Internet at the following URL:
- More information is available about Unicode.
- The EbcdicToAscii method converts an EBCDIC string to ASCII.