Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
15
Task/Character-codes/Ballerina/character-codes.ballerina
Normal file
15
Task/Character-codes/Ballerina/character-codes.ballerina
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import ballerina/io;
|
||||
|
||||
public function main() returns error? {
|
||||
int[] cps = [];
|
||||
foreach string c in ["a", "π", "字", "🐘"] {
|
||||
int cp = c[0].toCodePointInt();
|
||||
cps.push(cp);
|
||||
io:println(`${c} = ${cp}`);
|
||||
}
|
||||
io:println();
|
||||
foreach int i in cps {
|
||||
var c = check string:fromCodePointInt(i);
|
||||
io:println(`${i} = ${c}`);
|
||||
}
|
||||
}
|
||||
2
Task/Character-codes/Crystal/character-codes.cr
Normal file
2
Task/Character-codes/Crystal/character-codes.cr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
'Ω'.ord # => 937
|
||||
937.chr # => 'Ω'
|
||||
|
|
@ -7,16 +7,33 @@ Print ChrCode$(ChrCode("a"))
|
|||
|
||||
\\ (,) is an empty array.
|
||||
|
||||
Function Codes(a$) {
|
||||
If Len(A$)=0 then =(,) : Exit
|
||||
Buffer Mem as byte*Len(a$)
|
||||
\\ Str$(string) return one byte character
|
||||
Return Mem, 0:=Str$(a$)
|
||||
Inventory Codes
|
||||
For i=0 to len(Mem)-1
|
||||
Append Codes, i:=Eval(Mem, i)
|
||||
Next i
|
||||
=Codes
|
||||
Function Codes(a$, localeID=1033) {
|
||||
If Len(A$)=0 then =(,) : Exit
|
||||
\\ Str$(string) return one byte character
|
||||
oldlocale=locale
|
||||
locale localeID
|
||||
a=Str$(a$)
|
||||
locale oldlocale
|
||||
Codes=(,)
|
||||
locale 1033
|
||||
// 1 byte length returns 0.5 from len() ' 1 for 2 bytes.
|
||||
// chr$(string) convert to UTF16LE with current LOCALE
|
||||
For i=1 to len(a)*2
|
||||
Append Codes, (chrcode(chr$(mid$(a,i,1 as byte))),)
|
||||
Next i
|
||||
locale oldlocale
|
||||
=Codes
|
||||
}
|
||||
Print Codes("abcd")
|
||||
\\ 97 98 99 100
|
||||
Print Codes("abcdΩ", 1032)#str$(", ")
|
||||
\\ 97, 98, 99, 100, 217
|
||||
|
||||
Function CodesUNICODE(a) {
|
||||
If Len(a)=0 then =(,) : Exit
|
||||
Codes=(,)
|
||||
For i=1 to len(a)
|
||||
Append Codes, (chrcode(mid$(a,i,1)),)
|
||||
Next i
|
||||
=Codes
|
||||
}
|
||||
Print CodesUNICODE("abcdΩ")#str$(", ")
|
||||
\\ 97, 98, 99, 100, 937
|
||||
|
|
|
|||
5
Task/Character-codes/OPL/character-codes.opl
Normal file
5
Task/Character-codes/OPL/character-codes.opl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
PROC main:
|
||||
PRINT "a ->",ASC("a")
|
||||
PRINT "97 ->",CHR$(97)
|
||||
GET
|
||||
ENDP
|
||||
14
Task/Character-codes/S-BASIC/character-codes.basic
Normal file
14
Task/Character-codes/S-BASIC/character-codes.basic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
var ch = char
|
||||
var n = integer
|
||||
|
||||
ch = 'a'
|
||||
n = ch
|
||||
print ch; " = "; n
|
||||
print ch; " = "; asc(ch)
|
||||
|
||||
n = 97
|
||||
ch = n
|
||||
print n; " = "; ch
|
||||
print n; " = "; chr$(n)
|
||||
|
||||
end
|
||||
|
|
@ -1,26 +1,19 @@
|
|||
( uxnasm char-codes.tal char-codes.rom && uxncli char-codes.rom )
|
||||
%\n { 0a }
|
||||
%newline { [ LIT2 \n -Console/write ] DEO }
|
||||
|
||||
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|
||||
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
||||
|18 @Console/write
|
||||
|
||||
|0100
|
||||
[ LIT "a ] print-hex
|
||||
newline
|
||||
#61 .Console/write DEO
|
||||
newline
|
||||
|100
|
||||
|
||||
[ LIT "a ] print/byte newline
|
||||
#61 .Console/write DEO newline
|
||||
|
||||
( exit )
|
||||
#80 .System/state DEO
|
||||
BRK
|
||||
|
||||
@print-hex
|
||||
DUP #04 SFT print-digit #0f AND print-digit
|
||||
JMP2r
|
||||
|
||||
@print-digit
|
||||
DUP #09 GTH #27 MUL ADD #30 ADD .Console/write DEO
|
||||
JMP2r
|
||||
|
||||
@newline
|
||||
#0a .Console/write DEO
|
||||
JMP2r
|
||||
@print/byte ( byte -- )
|
||||
DUP #04 SFT /nibble
|
||||
( >> )
|
||||
|
||||
@print/nibble ( byte -- )
|
||||
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD .Console/write DEO
|
||||
JMP2r
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue