langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
23
Task/Character-codes/NetRexx/character-codes.netrexx
Normal file
23
Task/Character-codes/NetRexx/character-codes.netrexx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
runSample(arg)
|
||||
return
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method runSample(arg) private static
|
||||
-- create some sample data: character, hex and unicode
|
||||
samp = ' ' || 'a'.sequence('e') || '$' || '\xa2'.sequence('\xa5') || '\u20a0'.sequence('\u20b5')
|
||||
-- use the C2D C2X D2C and X2C built-in functions
|
||||
say "'"samp"'"
|
||||
say ' | Chr C2D C2X D2C X2C'
|
||||
say '---+ --- ------ ---- --- ---'
|
||||
loop ci = 1 to samp.length
|
||||
cc = samp.substr(ci, 1)
|
||||
cd = cc.c2d -- char to decimal
|
||||
cx = cc.c2x -- char to hexadecimal
|
||||
dc = cd.d2c -- decimal to char
|
||||
xc = cx.x2c -- hexadecimal to char
|
||||
say ci.right(3)"| '"cc"'" cd.right(6) cx.right(4, 0) "'"dc"' '"xc"'"
|
||||
end ci
|
||||
return
|
||||
2
Task/Character-codes/OCaml/character-codes-1.ocaml
Normal file
2
Task/Character-codes/OCaml/character-codes-1.ocaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Printf.printf "%d\n" (int_of_char 'a'); (* prints "97" *)
|
||||
Printf.printf "%c\n" (char_of_int 97); (* prints "a" *)
|
||||
4
Task/Character-codes/OCaml/character-codes-2.ocaml
Normal file
4
Task/Character-codes/OCaml/character-codes-2.ocaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Char.code ;;
|
||||
- : char -> int = <fun>
|
||||
# Char.chr;;
|
||||
- : int -> char = <fun>
|
||||
11
Task/Character-codes/Oberon-2/character-codes.oberon-2
Normal file
11
Task/Character-codes/Oberon-2/character-codes.oberon-2
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
MODULE Ascii;
|
||||
IMPORT Out;
|
||||
VAR
|
||||
c: CHAR;
|
||||
d: INTEGER;
|
||||
BEGIN
|
||||
c := CHR(97);
|
||||
d := ORD("a");
|
||||
Out.Int(d,3);Out.Ln;
|
||||
Out.Char(c);Out.Ln
|
||||
END Ascii.
|
||||
2
Task/Character-codes/Objeck/character-codes.objeck
Normal file
2
Task/Character-codes/Objeck/character-codes.objeck
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
'a'->As(Int)->PrintLine();
|
||||
97->As(Char)->PrintLine();
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
MESSAGE
|
||||
CHR(97) SKIP
|
||||
ASC("a")
|
||||
VIEW-AS ALERT-BOX.
|
||||
2
Task/Character-codes/Oz/character-codes.oz
Normal file
2
Task/Character-codes/Oz/character-codes.oz
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
{System.show &a} %% prints "97"
|
||||
{System.showInfo [97]} %% prints "a"
|
||||
2
Task/Character-codes/PARI-GP/character-codes.pari
Normal file
2
Task/Character-codes/PARI-GP/character-codes.pari
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print(Vecsmall("a")[1]);
|
||||
print(Strchr([72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33]))
|
||||
5
Task/Character-codes/PL-I/character-codes.pli
Normal file
5
Task/Character-codes/PL-I/character-codes.pli
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
declare 1 u union,
|
||||
2 c character (1),
|
||||
2 i fixed binary (8) unsigned;
|
||||
c = 'a'; put skip list (i); /* prints 97 */
|
||||
i = 97; put skip list (c); /* prints 'a' */
|
||||
2
Task/Character-codes/Pascal/character-codes.pascal
Normal file
2
Task/Character-codes/Pascal/character-codes.pascal
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
writeln(ord('a'));
|
||||
writeln(chr(97));
|
||||
2
Task/Character-codes/Perl-6/character-codes.pl6
Normal file
2
Task/Character-codes/Perl-6/character-codes.pl6
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
say ord('𪚥').fmt('0x%04x');
|
||||
say chr(0x2a6a5);
|
||||
1
Task/Character-codes/PowerShell/character-codes-1.psh
Normal file
1
Task/Character-codes/PowerShell/character-codes-1.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
$char = [char] 'a'
|
||||
1
Task/Character-codes/PowerShell/character-codes-2.psh
Normal file
1
Task/Character-codes/PowerShell/character-codes-2.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
$charcode = [int] $char # => 97
|
||||
1
Task/Character-codes/PowerShell/character-codes-3.psh
Normal file
1
Task/Character-codes/PowerShell/character-codes-3.psh
Normal file
|
|
@ -0,0 +1 @@
|
|||
[int] [char] '☺' # => 9786
|
||||
2
Task/Character-codes/PowerShell/character-codes-4.psh
Normal file
2
Task/Character-codes/PowerShell/character-codes-4.psh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[char] 97 # a
|
||||
[char] 9786 # ☺
|
||||
11
Task/Character-codes/PureBasic/character-codes-1.purebasic
Normal file
11
Task/Character-codes/PureBasic/character-codes-1.purebasic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
If OpenConsole()
|
||||
;Results are the same when compiled for Ascii or Unicode
|
||||
charCode.c = 97
|
||||
Char.s = "a"
|
||||
PrintN(Chr(charCode)) ;prints a
|
||||
PrintN(Str(Asc(Char))) ;prints 97
|
||||
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
|
||||
Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
11
Task/Character-codes/PureBasic/character-codes-2.purebasic
Normal file
11
Task/Character-codes/PureBasic/character-codes-2.purebasic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
If OpenConsole()
|
||||
;UTF-8 encoding compiled for Unicode (UCS-2)
|
||||
charCode.c = 960
|
||||
Char.s = "π"
|
||||
PrintN(Chr(charCode)) ;prints π
|
||||
PrintN(Str(Asc(Char))) ;prints 960
|
||||
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
|
||||
Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
1
Task/Character-codes/Retro/character-codes.retro
Normal file
1
Task/Character-codes/Retro/character-codes.retro
Normal file
|
|
@ -0,0 +1 @@
|
|||
'c putc
|
||||
2
Task/Character-codes/Run-BASIC/character-codes.run
Normal file
2
Task/Character-codes/Run-BASIC/character-codes.run
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print chr$(97) 'prints a
|
||||
print asc("a") 'prints 97
|
||||
14
Task/Character-codes/SNOBOL4/character-codes.sno
Normal file
14
Task/Character-codes/SNOBOL4/character-codes.sno
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
define('chr(n)') :(chr_end)
|
||||
chr &alphabet tab(n) len(1) . chr :s(return)f(freturn)
|
||||
chr_end
|
||||
|
||||
define('asc(str)c') :(asc_end)
|
||||
asc str len(1) . c
|
||||
&alphabet break(c) @asc :s(return)f(freturn)
|
||||
asc_end
|
||||
|
||||
* # Test and display
|
||||
output = char(65) ;* Built-in
|
||||
output = chr(65)
|
||||
output = asc('A')
|
||||
end
|
||||
2
Task/Character-codes/Seed7/character-codes.seed7
Normal file
2
Task/Character-codes/Seed7/character-codes.seed7
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
writeln(ord('a'));
|
||||
writeln(chr(97));
|
||||
2
Task/Character-codes/Slate/character-codes.slate
Normal file
2
Task/Character-codes/Slate/character-codes.slate
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$a code.
|
||||
97 as: String Character.
|
||||
2
Task/Character-codes/Standard-ML/character-codes.ml
Normal file
2
Task/Character-codes/Standard-ML/character-codes.ml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
print (Int.toString (ord #"a") ^ "\n"); (* prints "97" *)
|
||||
print (Char.toString (chr 97) ^ "\n"); (* prints "a" *)
|
||||
4
Task/Character-codes/TI-83-BASIC/character-codes.ti-83
Normal file
4
Task/Character-codes/TI-83-BASIC/character-codes.ti-83
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789→Str1
|
||||
Disp inString(Str1,"A
|
||||
Input "CODE? ",A
|
||||
Disp sub(Str1,A,1
|
||||
21
Task/Character-codes/TI-89-BASIC/character-codes.ti-89
Normal file
21
Task/Character-codes/TI-89-BASIC/character-codes.ti-89
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
Prgm
|
||||
Local k, s
|
||||
ClrIO
|
||||
Loop
|
||||
Disp "Press a key, or ON to exit."
|
||||
getKey() © clear buffer
|
||||
0 → k : While k = 0 : getKey() → k : EndWhile
|
||||
ClrIO
|
||||
If k ≥ 256 Then
|
||||
Disp "Not a character."
|
||||
Disp "Code: " & string(k)
|
||||
Else
|
||||
|
||||
char(k) → s ©
|
||||
© char() and ord() are inverses. ©
|
||||
Disp "Character: " & s ©
|
||||
Disp "Code: " & string(ord(s)) ©
|
||||
|
||||
EndIf
|
||||
EndLoop
|
||||
EndPrgm
|
||||
3
Task/Character-codes/TUSCRIPT/character-codes.tuscript
Normal file
3
Task/Character-codes/TUSCRIPT/character-codes.tuscript
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
$$ MODE TUSCRIPT
|
||||
SET character ="a", code=DECODE (character,byte)
|
||||
PRINT character,"=",code
|
||||
2
Task/Character-codes/Trith/character-codes-1.trith
Normal file
2
Task/Character-codes/Trith/character-codes-1.trith
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"a" ord print
|
||||
97 chr print
|
||||
2
Task/Character-codes/Trith/character-codes-2.trith
Normal file
2
Task/Character-codes/Trith/character-codes-2.trith
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
"π" ord print
|
||||
960 chr print
|
||||
9
Task/Character-codes/Ursala/character-codes.ursala
Normal file
9
Task/Character-codes/Ursala/character-codes.ursala
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#import std
|
||||
#import nat
|
||||
|
||||
chr = -: num characters
|
||||
asc = -:@rlXS num characters
|
||||
|
||||
#cast %cnX
|
||||
|
||||
test = (chr97,asc`a)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Console.WriteLine(Chr(97)) 'Prints a
|
||||
Console.WriteLine(Asc("a")) 'Prints 97
|
||||
2
Task/Character-codes/XPL0/character-codes.xpl0
Normal file
2
Task/Character-codes/XPL0/character-codes.xpl0
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
IntOut(0, ^a); \(Integer Out) displays "97" on the console (device 0)
|
||||
ChOut(0, 97); \(Character Out) displays "a" on the console (device 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue