AsciiToEbcdic (String function): Difference between revisions
m (1 revision) |
m (first pass, match syntax diagram to template and fix tags; still some broken links) |
||
Line 1: | Line 1: | ||
{{Template:String:AsciiToEbcdic subtitle}} | {{Template:String:AsciiToEbcdic subtitle}} | ||
<var>AsciiToEbcdic</var> is an <var>[[Intrinsic classes|intrinsic]]</var> function to convert an ASCII (ISO-8859-1) string to EBCDIC using the current <var>[[Unicode]]</var> tables. Optionally, untranslatable characters are represented with character references. | |||
==Syntax== | ==Syntax== | ||
{{Template:String:AsciiToEbcdic syntax}} | {{Template:String:AsciiToEbcdic syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>% | <tr><th>%string</th> | ||
<td>A string variable to receive the method object string translated to EBCDIC. | <td>A string variable to receive the method object string translated to EBCDIC.</td></tr> | ||
<tr><th>string</th> | <tr><th><var class="term">string</var></th> | ||
<td>A string that is presumed to consist of ASCII characters. | <td>A string that is presumed to consist of ASCII characters.</td></tr> | ||
<tr><th>CharacterEncode | <tr><th>CharacterEncode</th> | ||
<td>The optional | <td>The optional, but <var>[[Methods#Named parameters|NameRequired]]</var>, argument <var class="term">CharacterEncode</var> argument is a <var>[[Boolean]]</var>; if you specify a value, the parameter name <var class="term">CharacterEncode</var> is required.<ul><li>If its value is <code>False</code>, the default, an exception is thrown if the input <var class="term">string</var> contains any ASCII character not translatable to EBCDIC.<li>If its value is <code>True</code>, 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>For instance, the six characters <code>'&#x90;'</code> replace the ASCII <i>"Device Control String"</i> character (X'90'). A similar example is shown below.</ul></td></tr> | ||
</table> | </table> | ||
==Exceptions== | |||
<var>AsciiToEbcdic</var> can throw the following exception: | |||
<dl> | <dl> | ||
<dt>[[CharacterTranslationException]] | <dt><var>[[CharacterTranslationException class|CharacterTranslationException]]</var> | ||
<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== | ||
<ul><li>More information is available about the [[Unicode Tables|Unicode tables]]. | |||
<li>The <var>AsciiToEbcdic</var> function is available as of <var class="product">Sirius Mods</var> version 7.3.</ul> | |||
==Examples== | ==Examples== | ||
<ol><li> | |||
The following fragment shows calls of <var>AsciiToEbcdic</var> against strings with and | The following fragment shows calls of <var>AsciiToEbcdic</var> against strings with and without non-translatable characters. | ||
without non-translatable characters. | |||
<p class="code">%a <var>String</var> Len 20 | <p class="code">%a <var>String</var> Len 20 | ||
%a = [[ | %a = [[Intrinsic X function|'31':X]] | ||
Print %a:<var>AsciiToEbcdic</var> | Print %a:<var>AsciiToEbcdic</var> | ||
Line 50: | Line 43: | ||
</p> | </p> | ||
</ol> | |||
==See also== | ==See also== | ||
<ul><li>The inverse of the <var>AsciiToEbcdic</var> method is <var>[[EbcdicToAscii (String function) | EbcdicToAscii]]</var>.</ul> | |||
{{Template:String:AsciiToEbcdic footer}} | {{Template:String:AsciiToEbcdic footer}} |
Revision as of 03:08, 31 January 2011
Convert ASCII string to EBCDIC (String class)
AsciiToEbcdic is an intrinsic function to convert 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
%string | A string variable to receive the method object string translated to EBCDIC. |
---|---|
string | A string that is presumed to consist of ASCII characters. |
CharacterEncode | The optional, but NameRequired, argument CharacterEncode argument is a Boolean; if you specify a value, the parameter name CharacterEncode is required.
|
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: CHARACTER TRANSLATIONEXCEPTION exception: ASCII character X'81' without valid translation to EBCDIC at byte position 1 ...
See also
- The inverse of the AsciiToEbcdic method is EbcdicToAscii.