2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,5 +1,9 @@
|
|||
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
|
||||
;Task:
|
||||
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
|
||||
|
||||
For example, the character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
|
||||
|
||||
;Example:
|
||||
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
|
||||
|
||||
Conversely, given a code, print out the corresponding character.
|
||||
<br><br>
|
||||
|
|
|
|||
2
Task/Character-codes/APL/character-codes-1.apl
Normal file
2
Task/Character-codes/APL/character-codes-1.apl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
⎕UCS 97
|
||||
a
|
||||
2
Task/Character-codes/APL/character-codes-2.apl
Normal file
2
Task/Character-codes/APL/character-codes-2.apl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
⎕UCS 'a'
|
||||
97
|
||||
4
Task/Character-codes/APL/character-codes-3.apl
Normal file
4
Task/Character-codes/APL/character-codes-3.apl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
⎕UCS 65 80 76
|
||||
APL
|
||||
⎕UCS 'Hello, world!'
|
||||
72 101 108 108 111 44 32 119 111 114 108 100 33
|
||||
9
Task/Character-codes/COBOL/character-codes.cobol
Normal file
9
Task/Character-codes/COBOL/character-codes.cobol
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
identification division.
|
||||
program-id. character-codes.
|
||||
remarks. COBOL is an ordinal language, first is 1.
|
||||
remarks. 42nd ASCII code is ")" not, "*".
|
||||
procedure division.
|
||||
display function char(42)
|
||||
display function ord('*')
|
||||
goback.
|
||||
end program character-codes.
|
||||
5
Task/Character-codes/Io/character-codes.io
Normal file
5
Task/Character-codes/Io/character-codes.io
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"a" at(0) println // --> 97
|
||||
97 asCharacter println // --> a
|
||||
|
||||
"π" at(0) println // --> 960
|
||||
960 asCharacter println // --> π
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
print ord('a') # prints "97"
|
||||
print chr(97) # prints "a"
|
||||
print chr(97) # prints "a"
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
print ord(u'π') # prints "960"
|
||||
print ord(u'π') # prints "960"
|
||||
print unichr(960) # prints "π"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
print(ord('a')) # prints "97"
|
||||
print(ord('a')) # prints "97" (will also work in 2.x)
|
||||
print(ord('π')) # prints "960"
|
||||
print(chr(97)) # prints "a"
|
||||
print(chr(97)) # prints "a" (will also work in 2.x)
|
||||
print(chr(960)) # prints "π"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,26 @@
|
|||
yyy='c' /*assign a lowercase c to YYY.*/
|
||||
yyy='34'x /*assign hexadecimal 34 to YYY.*/
|
||||
/*the X can be upper/lowercase.*/
|
||||
yyy=x2c(34) /* (same as above) */
|
||||
yyy='00110100'b /* (same as above) */
|
||||
yyy='0011 0100'b /* (same as above) */
|
||||
/*the B can be upper/lowercase.*/
|
||||
yyy=d2c(97) /*assign decimal code 97 to YYY.*/
|
||||
/*REXX program displays a char's ASCII code/value (or EBCDIC if run on an EBCDIC system)*/
|
||||
yyy= 'c' /*assign a lowercase c to YYY. */
|
||||
yyy= "c" /* (same as above) */
|
||||
say 'from char, yyy code=' yyy
|
||||
|
||||
say yyy /*displays the value of YYY. */
|
||||
say c2x(yyy) /*displays the value of YYY in hexadecimal. */
|
||||
say c2d(yyy) /*displays the value of YYY in decimal. */
|
||||
say x2b(c2x(yyy)) /*displays the value of YYY in binary (bit string). */
|
||||
/*Note: some REXXes support the c2b bif */
|
||||
yyy= '63'x /*assign hexadecimal 63 to YYY. */
|
||||
yyy= '63'X /* (same as above) */
|
||||
say 'from hex, yyy code=' yyy
|
||||
|
||||
yyy= x2c(63) /*assign hexadecimal 63 to YYY. */
|
||||
say 'from hex, yyy code=' yyy
|
||||
|
||||
yyy= '01100011'b /*assign a binary 0011 0100 to YYY. */
|
||||
yyy= '0110 0011'b /* (same as above) */
|
||||
yyy= '0110 0011'B /* " " " */
|
||||
say 'from bin, yyy code=' yyy
|
||||
|
||||
yyy= d2c(99) /*assign decimal code 99 to 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 */
|
||||
say ' dec code: ' c2d(yyy) /* decimal */
|
||||
say ' bin code: ' x2b( c2x(yyy) ) /* binary (as a bit string) */
|
||||
/*stick a fork in it, we're all done with display*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
10 PRINT CHR$ 97: REM prints a
|
||||
20 PRINT CODE "a": REM prints 97
|
||||
Loading…
Add table
Add a link
Reference in a new issue