Character codes: Difference between revisions

Content added Content deleted
m (→‎[[Character code#ALGOL 68]]: character conversion routines)
Line 9: Line 9:
printf(($gl$, REPR 97)) # for ASCII this prints "a"; EBCDIC prints "/" #
printf(($gl$, REPR 97)) # for ASCII this prints "a"; EBCDIC prints "/" #
)
)
''Character conversions'' may be available in the ''standard preclude'' so that when
a foreign tape is mounted, the characters will be converted transparently as the tape's
records are read.
FILE tape;
INT errno = open(tape, "/dev/tape1", stand out channel)
make conv(tape, ebcdic conv);
FOR record DO getf(tape, ( ~ )) OD; ~ # etc ... #
Every CHANNEL has an associated standard character conversion that can be determined
using the ''stand conv'' query routine and then the conversion applied to a particular
file/tape. eg.
make conv(tape, stand conv(stand out channel))

=={{header|C}}==
=={{header|C}}==
<code>char</code> is already an integer type in C, and it gets automatically promoted to <code>int</code>. So you can use a character where you would otherwise use an integer. Conversely, you can use an integer where you would normally use a character, except you may need to cast it, as <code>char</code> is smaller.
<code>char</code> is already an integer type in C, and it gets automatically promoted to <code>int</code>. So you can use a character where you would otherwise use an integer. Conversely, you can use an integer where you would normally use a character, except you may need to cast it, as <code>char</code> is smaller.