UnicodeToEbcdic (Unicode function): Difference between revisions
m (→Syntax terms) |
m (→Examples) |
||
Line 44: | Line 44: | ||
The following example shows multiple calls of <var>UnicodeToEbcdic</var>. | The following example shows multiple calls of <var>UnicodeToEbcdic</var>. | ||
The [[U (String function)|U constant function]] is used in the example. | The [[U (String function)|U constant function]] is used in the example. | ||
<p class="code">%u | <p class="code">%u Unicode Initial('&#x31;':U) | ||
Print %u: | Print %u:UnicodeToEbcdic | ||
%u = '1&#x80;2':U | %u = '1&#x80;2':U | ||
Print %u: | Print %u:UnicodeToEbcdic(CharacterEncode=True) | ||
Print %u: | Print %u:UnicodeToEbcdic | ||
</p> | </p> | ||
The result of the above fragment is: | The result of the above fragment is: | ||
Line 56: | Line 56: | ||
CANCELLING REQUEST: MSIR.0751: Class STRING, function | CANCELLING REQUEST: MSIR.0751: Class STRING, function | ||
<p class="code">UNICODETOEBCDIC: CHARACTER TRANSLATIONEXCEPTION | <p class="code">UNICODETOEBCDIC: CHARACTER TRANSLATIONEXCEPTION | ||
exception: | exception: Unicode character U+0080 without valid | ||
translation to EBCDIC at byte position 5 ... | translation to EBCDIC at byte position 5 ... | ||
</p> | </p> | ||
Line 63: | Line 63: | ||
Because of the implicit conversion of <var>Unicode</var> strings (in this case to <var>String</var>), | Because of the implicit conversion of <var>Unicode</var> strings (in this case to <var>String</var>), | ||
<br> | <br> | ||
the <tt>Print %u: | the <tt>Print %u:UnicodeToEbcdic</tt> statements in the example above could be | ||
<br> | <br> | ||
replaced by <tt>Print %u</tt> statements and the results would be the same. | replaced by <tt>Print %u</tt> statements and the results would be the same. | ||
==See also== | ==See also== | ||
{{Template:Unicode:UnicodeToEbcdic footer}} | {{Template:Unicode:UnicodeToEbcdic footer}} |
Revision as of 22:10, 6 February 2011
Translate to Ebcdic (Unicode class)
This function converts a Unicode string to EBCDIC.
As an option,
untranslatable characters can be represented with XML style hexadecimal
character references.
The UnicodeToEbcdic function is available as of version 7.3 of the Sirius Mods.
Syntax
%string = unicode:UnicodeToEbcdic[( [CharacterEncode= boolean])] Throws CharacterTranslationException
Syntax terms
%ebcdic | A string variable to receive the method object string translated to EBCDIC. |
---|---|
unicode | A Unicode string. |
CharacterEncode=bool | The optional (name required) CharacterEncode argument is a Boolean:
|
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. See CharacterTranslationException exception class.
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 example in "Examples," below.
- The EbcdicToUnicode method converts an EBCDIC string to Unicode.
Examples
The following example shows multiple calls of UnicodeToEbcdic. The U constant function is used in the example.
%u Unicode Initial('1':U) Print %u:UnicodeToEbcdic %u = '1€2':U Print %u:UnicodeToEbcdic(CharacterEncode=True) Print %u:UnicodeToEbcdic
The result of the above fragment is:
1 1€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.