AsciiToEbcdic (String function): Difference between revisions
m (→Syntax terms) |
m (→Examples) |
||
(8 intermediate revisions by 3 users not shown) | |||
Line 19: | Line 19: | ||
<li><var>False</var>, the default, an exception is thrown if the input <var class="term">string</var> contains any ASCII character not translatable to EBCDIC. | <li><var>False</var>, the default, an exception is thrown if the input <var class="term">string</var> contains any ASCII character not translatable to EBCDIC. | ||
<li><var>True</var>, any ASCII character not translatable to EBCDIC is replaced with the XML style hexadecimal character reference of the character, and the ampersand character is replaced with <code>'&'</code>. | <li><var>True</var>, any ASCII character not translatable to EBCDIC is replaced with the XML style hexadecimal character reference of the character, and the ampersand character is replaced with <code>'&amp;'</code>. | ||
<li>For instance, the six characters <code>&#x90;</code> replace the ASCII "Device Control String" character (X'90'). A similar example is shown below. | <li>For instance, the six characters <code>&#x90;</code> replace the ASCII "Device Control String" character (X'90'). A similar example is shown below. | ||
Line 49: | Line 49: | ||
The result is: | The result is: | ||
<p class="output">1 | <p class="output">1 | ||
12 | 1&#x81;2 | ||
CANCELLING REQUEST: MSIR.0751: Class STRING, function ASCIITOEBCDIC: | CANCELLING REQUEST: MSIR.0751: Class STRING, function ASCIITOEBCDIC: CHARACTERTRANSLATIONEXCEPTION exception: ASCII character X'81' without valid translation to EBCDIC at byte position 1 ... | ||
</p> | </p> | ||
Latest revision as of 20:46, 15 February 2014
Convert ASCII string to EBCDIC (String class)
AsciiToEbcdic is an intrinsic function that converts an ASCII (ISO-8859-1) string to EBCDIC using the current Unicode tables. Optionally, untranslatable characters are represented with character references.
Syntax
%outString = string:AsciiToEbcdic[( [CharacterEncode= boolean])] Throws CharacterTranslationException
Syntax terms
%outString | A string variable to receive the method object string translated to EBCDIC. |
---|---|
string | The input string, which is presumed to consist of ASCII characters. |
CharacterEncode | The optional, name required, CharacterEncode argument is a Boolean enumeration. If its value is:
|
Exceptions
AsciiToEbcdic 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
- More information is available about the Unicode tables.
- The AsciiToEbcdic function is available as of Sirius Mods version 7.3.
Examples
The following fragment shows calls of AsciiToEbcdic against strings with and without non-translatable characters.
%a string Len 20 %a = '31':X Print %a:AsciiToEbcdic %a = '318132':X Print %a:AsciiToEbcdic(CharacterEncode=True) Print %a:AsciiToEbcdic
The result is:
1 12 CANCELLING REQUEST: MSIR.0751: Class STRING, function ASCIITOEBCDIC: CHARACTERTRANSLATIONEXCEPTION exception: ASCII character X'81' without valid translation to EBCDIC at byte position 1 ...
See also
- The inverse of the AsciiToEbcdic method is EbcdicToAscii.