UnicodeToEbcdic (Unicode function): Difference between revisions
m (1 revision) |
mNo edit summary |
||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
{{Template:Unicode:UnicodeToEbcdic syntax}} | {{Template:Unicode:UnicodeToEbcdic syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%string</th> | <tr><th>%string</th> | ||
<td>A string variable to receive the method object string translated to EBCDIC.</td></tr> | <td>A string variable to receive the method object string translated to EBCDIC.</td></tr> | ||
<tr><th>unicode</th> | <tr><th>unicode</th> | ||
<td>A <var>Unicode</var> string to be translated.</td></tr> | <td>A <var>Unicode</var> string to be translated.</td></tr> | ||
<tr><th><var>CharacterEncode</var></th> | <tr><th><var>CharacterEncode</var></th> | ||
<td>The optional ( | <td>The optional ([[Notation conventions for methods#Named parameters|name required]]) <var>CharacterEncode</var> argument is a <var>[[Boolean enumeration]]</var>: | ||
<ul> | |||
<li>If its value is <code>False</code>, the default, an exception is thrown if the input contains any Unicode character not translatable to EBCDIC. <li>If its value is <Code>True</code>, any Unicode character not translatable to EBCDIC is replaced with the hexadecimal character reference of the character, and the ampersand character is replaced with <code>&amp;</code>. For example, the eight characters <code>&#x201C;</code> replace the Unicode left double-quotation mark (<tt>“</tt>). | |||
</ul></td></tr> | |||
</table> | </table> | ||
Line 28: | Line 34: | ||
==Examples== | ==Examples== | ||
The following example shows multiple calls of <var>UnicodeToEbcdic</var>. | The following example shows multiple calls of <var>UnicodeToEbcdic</var>. | ||
<p class="code">%u Unicode Initial('&amp;#x31;':[[U (String function)|U]]) | <p class="code">%u Unicode Initial('&amp;#x31;':[[U (String function)|U]]) | ||
Line 47: | Line 52: | ||
<b>Note:</b> Because of the implicit conversion of <var>Unicode</var> strings (in this case to <var>String</var>), the <code>Print %u:UnicodeToEbcdic</code> statements in the example above could be replaced by | <b>Note:</b> Because of the implicit conversion of <var>Unicode</var> strings (in this case to <var>String</var>), the <code>Print %u:UnicodeToEbcdic</code> statements in the example above could be replaced by | ||
<code>Print %u</code> statements and the results would be the same. | <code>Print %u</code> statements and the results would be the same. | ||
==See also== | ==See also== | ||
<ul><li>The intrinsic <var>[[String class|String]]</var> method: <var>[[EbcdicToUnicode (String function)|EbcdicToUnicode]]</var> converts an EBCDIC string to <var>Unicode</var>.</ul> | <ul> | ||
<li>The intrinsic <var>[[String class|String]]</var> method: <var>[[EbcdicToUnicode (String function)|EbcdicToUnicode]]</var> converts an EBCDIC string to <var>Unicode</var>. | |||
</ul> | |||
{{Template:Unicode:UnicodeToEbcdic footer}} | {{Template:Unicode:UnicodeToEbcdic footer}} |
Revision as of 22:15, 7 August 2012
Translate to Ebcdic (Unicode class)
UnicodeToEbcdic converts a Unicode string to EBCDIC. Optionally, untranslatable characters can be represented with XML style hexadecimal character references.
Syntax
%string = unicode:UnicodeToEbcdic[( [CharacterEncode= boolean])] Throws CharacterTranslationException
Syntax terms
%string | A string variable to receive the method object string translated to EBCDIC. |
---|---|
unicode | A Unicode string to be translated. |
CharacterEncode | The optional (name required) CharacterEncode argument is a Boolean enumeration:
|
Exceptions
This function 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
- Unless the CharacterEncode argument is used, or you want to
Catch
a CharacterTranslationException, this function is generally not needed, because a Unicode string is implicitly converted to EBCDIC when used in an EBCDIC context. See the following example. - The UnicodeToEbcdic function is available as of Sirius Mods Version 7.3.
Examples
The following example shows multiple calls of UnicodeToEbcdic.
%u Unicode Initial('&#x31;':U) print %u:UnicodeToEbcdic %u = '1&#x80;2':U print %u:UnicodeToEbcdic(CharacterEncode=True) print %u:UnicodeToEbcdic
The result of the above fragment is:
1 1&#x0080;2 CANCELLING REQUEST: MSIR.0751: Class STRING, function UNICODETOEBCDIC: CHARACTER TRANSLATIONEXCEPTION exception: Unicode character U+0080 without valid translation to EBCDIC at byte position 5 ...
Note: Because of the implicit conversion of Unicode strings (in this case to String), the Print %u:UnicodeToEbcdic
statements in the example above could be replaced by
Print %u
statements and the results would be the same.
See also
- The intrinsic String method: EbcdicToUnicode converts an EBCDIC string to Unicode.