AsciiToEbcdic (String function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (1 revision) |
||
Line 2: | Line 2: | ||
This [[Intrinsic classes|intrinsic]] function converts an ASCII (ISO-8859-1) string to EBCDIC | This [[Intrinsic classes|intrinsic]] function converts an ASCII (ISO-8859-1) string to EBCDIC | ||
using the current Unicode tables. | using the current Unicode tables. | ||
Optionally, | Optionally, | ||
untranslatable characters are represented with character references. | untranslatable characters are represented with character references. | ||
The AsciiToEbcdic function is available as of version 7.3 of the [[Sirius Mods]]. | The AsciiToEbcdic function is available as of version 7.3 of the [[Sirius Mods]]. | ||
==Syntax== | ==Syntax== | ||
{{Template:String:AsciiToEbcdic syntax}} | {{Template:String:AsciiToEbcdic syntax}} | ||
Line 18: | Line 18: | ||
<td>The optional (name required) CharacterEncode argument is a Boolean: *If its value is ''''False'''', the default, an exception is thrown if the input contains any ASCII character not translatable to EBCDIC. *If its value is ''''True'''', 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 ''''&.amp;''''. For instance, the six characters '&#x90;' replace the ASCII ''Device Control String'' character (X'90'). A similar example is shown below.</td></tr> | <td>The optional (name required) CharacterEncode argument is a Boolean: *If its value is ''''False'''', the default, an exception is thrown if the input contains any ASCII character not translatable to EBCDIC. *If its value is ''''True'''', 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 ''''&.amp;''''. For instance, the six characters '&#x90;' replace the ASCII ''Device Control String'' character (X'90'). A similar example is shown below.</td></tr> | ||
</table> | </table> | ||
===Exceptions=== | ===Exceptions=== | ||
This [[Intrinsic classes|intrinsic]] function can throw the following exception: | This [[Intrinsic classes|intrinsic]] function can throw the following exception: | ||
<dl> | <dl> | ||
<dt>[[CharacterTranslationException]] | <dt>[[CharacterTranslationException]] | ||
<dd>If the method encounters a translation problem, | <dd>If the method encounters a translation problem, | ||
properties of the exception object may indicate the location and type of problem. | properties of the exception object may indicate the location and type of problem. | ||
</dl> | </dl> | ||
==Usage notes== | ==Usage notes== | ||
*More information is available about the [[Unicode Tables|Unicode tables]]. | *More information is available about the [[Unicode Tables|Unicode tables]]. | ||
*The inverse of the AsciiToEbcdic method is [[EbcdicToAscii (String function) | EbcdicToAscii]]. | *The inverse of the AsciiToEbcdic method is [[EbcdicToAscii (String function) | EbcdicToAscii]]. | ||
==Examples== | ==Examples== | ||
The following fragment shows calls of AsciiToEbcdic against strings with and | The following fragment shows calls of AsciiToEbcdic against strings with and | ||
without non-translatable characters. | without non-translatable characters. | ||
%a String Len 20 | %a String Len 20 | ||
%a = [[Intrinsix X function|'31':X]] | %a = [[Intrinsix X function|'31':X]] | ||
Print %a:AsciiToEbcdic | Print %a:AsciiToEbcdic | ||
%a = '318132':X | %a = '318132':X | ||
Print %a:AsciiToEbcdic(CharacterEncode=True) | Print %a:AsciiToEbcdic(CharacterEncode=True) | ||
Print %a:AsciiToEbcdic | Print %a:AsciiToEbcdic | ||
The result is: | The result is: | ||
1 | 1 | ||
1&#x81;2 | 1&#x81;2 | ||
CANCELLING REQUEST: MSIR.0751: Class STRING, function ASCIITOEBCDIC: CHARACTER TRANSLATIONEXCEPTION | CANCELLING REQUEST: MSIR.0751: Class STRING, function ASCIITOEBCDIC: CHARACTER TRANSLATIONEXCEPTION | ||
exception: ASCII character X'81' without valid translation to EBCDIC at byte position 1 ... | exception: ASCII character X'81' without valid translation to EBCDIC at byte position 1 ... | ||
===See also=== | ===See also=== | ||
[[List of intrinsic String methods]] | [[List of intrinsic String methods]] | ||
[[Category:Intrinsic String methods|AsciiToEbcdic function]] | [[Category:Intrinsic String methods|AsciiToEbcdic function]] | ||
[[Category:Intrinsic methods]] | [[Category:Intrinsic methods]] |
Revision as of 14:04, 19 January 2011
Convert ASCII string to EBCDIC (String class)
This intrinsic function converts an ASCII (ISO-8859-1) string to EBCDIC
using the current Unicode tables.
Optionally,
untranslatable characters are represented with character references.
The AsciiToEbcdic function is available as of version 7.3 of the Sirius Mods.
Syntax
%outString = string:AsciiToEbcdic[( [CharacterEncode= boolean])] Throws CharacterTranslationException
Syntax terms
%ebcdic | A string variable to receive the method object string translated to EBCDIC. |
---|---|
string | A string that is presumed to consist of ASCII characters. |
CharacterEncode=bool | The optional (name required) CharacterEncode argument is a Boolean: *If its value is 'False', the default, an exception is thrown if the input contains any ASCII character not translatable to EBCDIC. *If its value is 'True', 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 '&.amp;'. For instance, the six characters '' replace the ASCII Device Control String character (X'90'). A similar example is shown below. |
Exceptions
This intrinsic 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
- More information is available about the Unicode tables.
- The inverse of the AsciiToEbcdic method is EbcdicToAscii.
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: CHARACTER TRANSLATIONEXCEPTION exception: ASCII character X'81' without valid translation to EBCDIC at byte position 1 ...