Anonymous user
Character codes: Difference between revisions
m
→{{header|REXX}}: re-wrote the REXX program with more displays and more comments.
No edit summary |
m (→{{header|REXX}}: re-wrote the REXX program with more displays and more comments.) |
||
Line 1,086:
=={{header|REXX}}==
REXX supports handling of characters with built-in functions (BIFs), whether it be hexadecimal, binary (bits), or decimal
===
<lang rexx>
yyy= '
yyy= "c" /*
say 'from char, yyy code=' yyy
yyy=x2c(34) /* (same as above) */▼
yyy=d2c(97) /*assign decimal code 97 to YYY.*/▼
say 'from hex, yyy code=' yyy
say c2d(yyy) /*displays the value of YYY in decimal. */▼
say x2b(c2x(yyy)) /*displays the value of YYY in binary (bit string). */▼
yyy= x2c(63) /*
say 'from hex, yyy code=' yyy
===version 2 EBCDIC ===▼
yyy= '01100011'b /*assign a binary 0011 0100 to YYY. */
yyy= '0110 0011'B /* " " " */
say 'from bin, yyy code=' yyy
say 'from dec, yyy code=' yyy
say /* [↓] displays the value of YYY in ··· */
say 'char code: ' yyy /* character code (as an 8-bit ASCII character).*/
say ' hex code: ' c2x(yyy) /* hexadecimal */
/*stick a fork in it, we're all done with display*/</lang>
'''output'''
<pre>
from char, yyy code= c
from hex, yyy code= c
from hex, yyy code= c
from bin, yyy code= c
from dec, yyy code= c
char code: c
hex code: 63
dec code: 99
bin code: 01100011
</pre>
<lang rexx>/* REXX */
yyy='c' /*assign a lowercase c to YYY */
|