UnicodeToEbcdic (Unicode function): Difference between revisions
mNo edit summary |
m (→Usage notes) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 29: | Line 29: | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>Unless the <var | <li>Unless the <var>CharacterEncode</var> argument is used, or you want to <code>Catch</code> a <var>CharacterTranslationException</var>, this function is generally not needed, because a <var>Unicode</var> string is implicitly converted to EBCDIC when used in an EBCDIC context. See the following [[#Examples|example]]. | ||
<li>The <var>UnicodeToEbcdic</var> function is available as of <var class="product"> | <li>The <var>UnicodeToEbcdic</var> function is available as of <var class="product">Sirius Mods</var> Version 7.3. | ||
</ul> | </ul> | ||
==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('& | <p class="code">%u Unicode Initial('&#x31;':[[U (String function)|U]]) | ||
print %u:UnicodeToEbcdic | print %u:UnicodeToEbcdic | ||
%u = '1& | %u = '1&#x80;2':U | ||
print %u:UnicodeToEbcdic(CharacterEncode=True) | print %u:UnicodeToEbcdic(CharacterEncode=True) | ||
print %u:UnicodeToEbcdic | print %u:UnicodeToEbcdic | ||
Line 44: | Line 44: | ||
The result of the above fragment is: | The result of the above fragment is: | ||
<p class="output">1 | <p class="output">1 | ||
1& | 1&#x0080;2 | ||
CANCELLING REQUEST: MSIR.0751: Class STRING, function | CANCELLING REQUEST: MSIR.0751: Class STRING, function | ||
UNICODETOEBCDIC: CHARACTER TRANSLATIONEXCEPTION | UNICODETOEBCDIC: CHARACTER TRANSLATIONEXCEPTION |
Latest revision as of 20:03, 6 November 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('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.
See also
- The intrinsic String method: EbcdicToUnicode converts an EBCDIC string to Unicode.