Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,7 @@
---
category:
- Basic language learning
- String manipulation
- Simple
from: http://rosettacode.org/wiki/Character_codes
note: Text processing

View file

@ -0,0 +1,9 @@
;Task:
Given a character value in your language, print its code   (could be ASCII code, Unicode code, or whatever your language uses).
;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>

View file

@ -0,0 +1,2 @@
print(a.code) // prints "97"
print(Char(code' 97)) // prints "a"

View file

@ -0,0 +1,34 @@
* Character codes EBCDIC 15/02/2017
CHARCODE CSECT
USING CHARCODE,R13 base register
B 72(R15) skip savearea
DC 17F'0' savearea
STM R14,R12,12(R13) prolog
ST R13,4(R15) " <-
ST R15,8(R13) " ->
LR R13,R15 " addressability
* Character to Decimal
SR R1,R1 r1=0
IC R1,=C'a' insert character 'a'
XDECO R1,PG
XPRNT PG,L'PG print -> 129
* Hexadecimal to character
SR R1,R1 r1=0
IC R1,=X'81' insert character X'81'
STC R1,CHAR store character r1
XPRNT CHAR,L'CHAR print -> 'a'
* Decimal to character
LH R1,=H'129' r1=129
STC R1,CHAR store character r1
XPRNT CHAR,L'CHAR print -> 'a'
*
XDUMP CHAR,L'CHAR dump -> X'81'
*
RETURN L R13,4(0,R13) epilog
LM R14,R12,12(R13) " restore
XR R15,R15 " rc=0
BR R14 exit
PG DS CL12
CHAR DS CL1
YREGS
END CHARCODE

View file

@ -0,0 +1,74 @@
JSR ResetCoords ;RESET TYPING CURSOR
MOVE.B #'A',D1
MOVE.W #25,D2
MOVE.B #0,(softCarriageReturn) ;new line takes the cursor to left edge of screen.
jsr PrintAllTheCodes
jsr ResetCoords
MOVE.B #8,(Cursor_X)
MOVE.B #'a',D1
MOVE.W #25,D2
MOVE.B #8,(softCarriageReturn)
;set the writing cursor to column 3 of the screen
;so we don't erase the old output.
jsr PrintAllTheCodes
forever:
bra forever
PrintAllTheCodes:
MOVE.B D1,D0
jsr PrintChar ;print the character as-is
MOVE.B #" ",D0
jsr PrintChar
MOVE.B #"=",D0
jsr PrintChar
MOVE.B #" ",D0
jsr PrintChar
MOVE.B D1,D0 ;get ready to print the code
JSR UnpackNibbles8
SWAP D0
ADD.B #$30,D0
JSR PrintChar
SWAP D0
CMP.B #10,D0
BCS noCorrectHex
ADD.B #$07,D0
noCorrectHex:
ADD.B #$30,D0
JSR PrintChar
MOVE.B (softCarriageReturn),D0
JSR doNewLine2 ;new line, with D0 as the carraige return point.
ADDQ.B #1,D1
DBRA D2,PrintAllTheCodes
rts
UnpackNibbles8:
; INPUT: D0 = THE VALUE YOU WISH TO UNPACK.
; HIGH NIBBLE IN HIGH WORD OF D0, LOW NIBBLE IN LOW WORD. SWAP D0 TO GET THE OTHER HALF.
pushWord D1
CLR.W D1
MOVE.B D0,D1
CLR.L D0
MOVE.B D1,D0 ;now D0 = D1 = $000000II, where I = input
AND.B #$F0,D0 ;chop off bottom nibble
LSR.B #4,D0 ;downshift top nibble into bottom nibble of the word
SWAP D0 ;store in high word
AND.B #$0F,D1 ;chop off bottom nibble
MOVE.B D1,D0 ;store in low word
popWord D1
rts

View file

@ -0,0 +1,59 @@
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program character64.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
/*******************************************/
/* Initialized data */
/*******************************************/
.data
szMessCodeChar: .asciz "The code of character is : @ \n"
/*******************************************/
/* UnInitialized data */
/*******************************************/
.bss
sZoneconv: .skip 32
/*******************************************/
/* code section */
/*******************************************/
.text
.global main
main: // entry of program
mov x0,'A'
ldr x1,qAdrsZoneconv
bl conversion10S
ldr x0,qAdrszMessCodeChar
ldr x1,qAdrsZoneconv
bl strInsertAtCharInc // insert result at @ character
bl affichageMess
mov x0,'a'
ldr x1,qAdrsZoneconv
bl conversion10S
ldr x0,qAdrszMessCodeChar
ldr x1,qAdrsZoneconv
bl strInsertAtCharInc // insert result at @ character
bl affichageMess
mov x0,'1'
ldr x1,qAdrsZoneconv
bl conversion10S
ldr x0,qAdrszMessCodeChar
ldr x1,qAdrsZoneconv
bl strInsertAtCharInc // insert result at @ character
bl affichageMess
100: // standard end of the program */
mov x0,0 // return code
mov x8,EXIT // request to exit program
svc 0 // perform the system call
qAdrsZoneconv: .quad sZoneconv
qAdrszMessCodeChar: .quad szMessCodeChar
/********************************************************/
/* File Include fonctions */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"

View file

@ -0,0 +1,7 @@
report zcharcode
data: c value 'A', n type i.
field-symbols <n> type x.
assign c to <n> casting.
move <n> to n.
write: c, '=', n left-justified.

View file

@ -0,0 +1,2 @@
(cw "~x0" (char-code #\a))
(cw "~x0" (code-char 97))

View file

@ -0,0 +1,4 @@
main:(
printf(($gl$, ABS "a")); # for ASCII this prints "+97" EBCDIC prints "+129" #
printf(($gl$, REPR 97)) # for ASCII this prints "a"; EBCDIC prints "/" #
)

View file

@ -0,0 +1,4 @@
FILE tape;
INT errno = open(tape, "/dev/tape1", stand out channel)
make conv(tape, ebcdic conv);
FOR record DO getf(tape, ( ~ )) OD; ~ # etc ... #

View file

@ -0,0 +1 @@
make conv(tape, stand conv(stand out channel))

View file

@ -0,0 +1,6 @@
begin
% display the character code of "a" (97 in ASCII) %
write( decode( "a" ) );
% display the character corresponding to 97 ("a" in ASCII) %
write( code( 97 ) );
end.

View file

@ -0,0 +1,2 @@
⎕UCS 97
a

View file

@ -0,0 +1,2 @@
⎕UCS 'a'
97

View 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

View file

@ -0,0 +1,124 @@
/* ARM assembly Raspberry PI */
/* program character.s */
/* Constantes */
.equ STDOUT, 1 @ Linux output console
.equ EXIT, 1 @ Linux syscall
.equ WRITE, 4 @ Linux syscall
/* Initialized data */
.data
szMessCodeChar: .ascii "The code of character is :"
sZoneconv: .fill 12,1,' '
szCarriageReturn: .asciz "\n"
/* UnInitialized data */
.bss
/* code section */
.text
.global main
main: /* entry of program */
push {fp,lr} /* saves 2 registers */
mov r0,#'A'
ldr r1,iAdrsZoneconv
bl conversion10S
ldr r0,iAdrszMessCodeChar
bl affichageMess
mov r0,#'a'
ldr r1,iAdrsZoneconv
bl conversion10S
ldr r0,iAdrszMessCodeChar
bl affichageMess
mov r0,#'1'
ldr r1,iAdrsZoneconv
bl conversion10S
ldr r0,iAdrszMessCodeChar
bl affichageMess
100: /* standard end of the program */
mov r0, #0 @ return code
pop {fp,lr} @restaur 2 registers
mov r7, #EXIT @ request to exit program
swi 0 @ perform the system call
iAdrsZoneconv: .int sZoneconv
iAdrszMessCodeChar: .int szMessCodeChar
/******************************************************************/
/* display text with size calculation */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
push {fp,lr} /* save registres */
push {r0,r1,r2,r7} /* save others registers */
mov r2,#0 /* counter length */
1: /* loop length calculation */
ldrb r1,[r0,r2] /* read octet start position + index */
cmp r1,#0 /* if 0 its over */
addne r2,r2,#1 /* else add 1 in the length */
bne 1b /* and loop */
/* so here r2 contains the length of the message */
mov r1,r0 /* address message in r1 */
mov r0,#STDOUT /* code to write to the standard output Linux */
mov r7, #WRITE /* code call system "write" */
swi #0 /* call systeme */
pop {r0,r1,r2,r7} /* restaur others registers */
pop {fp,lr} /* restaur des 2 registres */
bx lr /* return */
/***************************************************/
/* conversion register signed décimal */
/***************************************************/
/* r0 contient le registre */
/* r1 contient l adresse de la zone de conversion */
conversion10S:
push {r0-r5,lr} /* save des registres */
mov r2,r1 /* debut zone stockage */
mov r5,#'+' /* par defaut le signe est + */
cmp r0,#0 /* nombre négatif ? */
movlt r5,#'-' /* oui le signe est - */
mvnlt r0,r0 /* et inversion en valeur positive */
addlt r0,#1
mov r4,#10 /* longueur de la zone */
1: /* debut de boucle de conversion */
bl divisionpar10 /* division */
add r1,#48 /* ajout de 48 au reste pour conversion ascii */
strb r1,[r2,r4] /* stockage du byte en début de zone r5 + la position r4 */
sub r4,r4,#1 /* position précedente */
cmp r0,#0
bne 1b /* boucle si quotient different de zéro */
strb r5,[r2,r4] /* stockage du signe à la position courante */
subs r4,r4,#1 /* position précedente */
blt 100f /* si r4 < 0 fin */
/* sinon il faut completer le debut de la zone avec des blancs */
mov r3,#' ' /* caractere espace */
2:
strb r3,[r2,r4] /* stockage du byte */
subs r4,r4,#1 /* position précedente */
bge 2b /* boucle si r4 plus grand ou egal a zero */
100: /* fin standard de la fonction */
pop {r0-r5,lr} /*restaur desregistres */
bx lr
/***************************************************/
/* division par 10 signé */
/* Thanks to http://thinkingeek.com/arm-assembler-raspberry-pi/*
/* and http://www.hackersdelight.org/ */
/***************************************************/
/* r0 contient le dividende */
/* r0 retourne le quotient */
/* r1 retourne le reste */
divisionpar10:
/* r0 contains the argument to be divided by 10 */
push {r2-r4} /* save registers */
mov r4,r0
ldr r3, .Ls_magic_number_10 /* r1 <- magic_number */
smull r1, r2, r3, r0 /* r1 <- Lower32Bits(r1*r0). r2 <- Upper32Bits(r1*r0) */
mov r2, r2, ASR #2 /* r2 <- r2 >> 2 */
mov r1, r0, LSR #31 /* r1 <- r0 >> 31 */
add r0, r2, r1 /* r0 <- r2 + r1 */
add r2,r0,r0, lsl #2 /* r2 <- r0 * 5 */
sub r1,r4,r2, lsl #1 /* r1 <- r4 - (r2 * 2) = r4 - (r0 * 10) */
pop {r2-r4}
bx lr /* leave function */
bx lr /* leave function */
.Ls_magic_number_10: .word 0x66666667

View file

@ -0,0 +1,13 @@
function ord(c)
{
return chmap[c]
}
BEGIN {
for(i=0; i < 256; i++) {
chmap[sprintf("%c", i)] = i
}
print ord("a"), ord("b")
printf "%c %c\n", 97, 98
s = sprintf("%c%c", 97, 98)
print s
}

View file

@ -0,0 +1,7 @@
PROC Main()
CHAR c=['a]
BYTE b=[97]
Put(c) Put('=) PrintBE(c)
PrintB(b) Put('=) Put(b)
RETURN

View file

@ -0,0 +1,2 @@
trace(String.fromCharCode(97)); //prints 'a'
trace("a".charCodeAt(0));//prints '97'

View file

@ -0,0 +1,6 @@
with Ada.Text_IO; use Ada.Text_IO;
procedure Char_Code is
begin
Put_Line (Character'Val (97) & " =" & Integer'Image (Character'Pos ('a')));
end Char_Code;

View file

@ -0,0 +1,6 @@
# prints "97"
o_integer('a');
o_byte('\n');
# prints "a"
o_byte(97);
o_byte('\n');

View file

@ -0,0 +1,2 @@
log(id of "a")
log(id of "aA")

View file

@ -0,0 +1,11 @@
character id 97
--> "a"
character id {72, 101, 108, 108, 111, 33}
--> "Hello!"
string id {72, 101, 108, 108, 111, 33}
--> "Hello!"
Unicode text id {72, 101, 108, 108, 111, 33}
--> "Hello!"

View file

@ -0,0 +1 @@
?CHR$(97)"="ASC(CHR$(97))

View file

@ -0,0 +1,3 @@
print to :integer first "a"
print to :integer `a`
print to :char 97

View file

@ -0,0 +1,2 @@
MsgBox % Chr(97)
MsgBox % Asc("a")

View file

@ -0,0 +1,2 @@
Disp 'a'▶Dec,i
Disp 97▶Char,i

View file

@ -0,0 +1,4 @@
charCode = 97
char = "a"
PRINT CHR$(charCode) 'prints a
PRINT ASC(char) 'prints 97

View file

@ -0,0 +1,4 @@
10 LET c = 97: REM c is a character code
20 LET d$ = "b": REM d$ holds the character
30 PRINT CHR$(c): REM this prints a
40 PRINT CODE(d$): REM this prints 98

View file

@ -0,0 +1,11 @@
# ASCII char
charCode = 97
char$ = "a"
print chr(97) #prints a
print asc("a") #prints 97
# Unicode char
charCode = 960
char$ = "π"
print chr(960) #prints π
print asc("π") #prints 960

View file

@ -0,0 +1,4 @@
charCode = 97
char$ = "a"
PRINT CHR$(charCode) : REM prints a
PRINT ASC(char$) : REM prints 97

View file

@ -0,0 +1,8 @@
FromCharCode @+
@+
FromCharCode 97
'a'
FromCharCode 9767126
"aC~"
FromCharCode 'a'
97

View file

@ -0,0 +1,7 @@
' ASCII
c$ = "$"
PRINT c$, ": ", ASC(c$)
' UTF-8
uc$ = "€"
PRINT uc$, ": ", UCS(uc$), ", ", UCS(c$)

View file

@ -0,0 +1,2 @@
'abcdefg' str2ar
{%d nl <<} eachar

View file

@ -0,0 +1 @@
(98 97 98 101 108) ls2lf ar2str nl <<

View file

@ -0,0 +1,33 @@
@echo off
:: Supports all ASCII characters and codes from 34-126 with the exceptions of:
:: 38 &
:: 60 <
:: 62 >
:: 94 ^
:: 124 |
:_main
call:_toCode a
call:_toChar 97
pause>nul
exit /b
:_toCode
setlocal enabledelayedexpansion
set codecount=32
for /l %%i in (33,1,126) do (
set /a codecount+=1
cmd /c exit %%i
if %1==!=exitcodeAscii! (
echo !codecount!
exit /b
)
)
:_toChar
setlocal
cmd /c exit %1
echo %=exitcodeAscii%
exit /b

View file

@ -0,0 +1 @@
"a". 99*44*+, @

View file

@ -0,0 +1,21 @@
( put
$ ( str
$ ( "\nLatin a
ISO-9959-1: "
asc$a
" = "
chr$97
"
UTF-8: "
utf$a
" = "
chu$97
\n
"Cyrillic а (UTF-8): "
utf$а
" = "
chu$1072
\n
)
)
)

View file

@ -0,0 +1,7 @@
#include <iostream>
int main() {
std::cout << (int)'a' << std::endl; // prints "97"
std::cout << (char)97 << std::endl; // prints "a"
return 0;
}

View file

@ -0,0 +1,13 @@
using System;
namespace RosettaCode.CharacterCode
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine((int) 'a'); //Prints "97"
Console.WriteLine((char) 97); //Prints "a"
}
}
}

View file

@ -0,0 +1,7 @@
#include <stdio.h>
int main() {
printf("%d\n", 'a'); /* prints "97" */
printf("%c\n", 97); /* prints "a"; we don't have to cast because printf is type agnostic */
return 0;
}

View file

@ -0,0 +1,11 @@
start_up = proc ()
po: stream := stream$primary_output()
% To turn a character code into an integer, use char$c2i
% (but then to print it, it needs to be turned into a string first
% with int$unparse)
stream$putl(po, int$unparse( char$c2i( 'a' ) ) ) % prints '97'
% To turn an integer into a character code, use char$i2c
stream$putc(po, char$i2c( 97 ) ); % prints 'a'
end start_up

View 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.

View file

@ -0,0 +1,10 @@
(print (int \a)) ; prints "97"
(print (char 97)) ; prints \a
; Unicode is also available, as Clojure uses the underlying java Strings & chars
(print (int )) ; prints 960
(print (char 960)) ; prints \π
; use String because char in Java can't represent characters outside Basic Multilingual Plane
(print (.codePointAt "𝅘𝅥𝅮" 0)) ; prints 119136
(print (String. (int-array 1 119136) 0 1)) ; prints 𝅘𝅥𝅮

View file

@ -0,0 +1,2 @@
console.log 'a'.charCodeAt 0 # 97
console.log String.fromCharCode 97 # a

View file

@ -0,0 +1,4 @@
10 CH = 65: REM IN PETSCII CODE FOR 'A' IS 65
20 D$ = "B": REM D$ HOLDS THE CHARACTER 'B'
30 PRINT CHR$(CH): REM THIS PRINTS 'A'
40 PRINT ASC(D$): REM THIS PRINTS 66

View file

@ -0,0 +1,2 @@
(princ (char-code #\a)) ; prints "97"
(princ (code-char 97)) ; prints "a"

View file

@ -0,0 +1,9 @@
PROCEDURE CharCodes*;
VAR
c : CHAR;
BEGIN
c := 'A';
StdLog.Char(c);StdLog.String(":> ");StdLog.Int(ORD(c));StdLog.Ln;
c := CHR(3A9H);
StdLog.Char(c);StdLog.String(":> ");StdLog.Int(ORD(c));StdLog.Ln
END CharCodes;

View file

@ -0,0 +1,12 @@
void main() {
import std.stdio, std.utf;
string test = "a";
size_t index = 0;
// Get four-byte utf32 value for index 0.
writefln("%d", test.decode(index));
// 'index' has moved to next character input position.
assert(index == 1);
}

View file

@ -0,0 +1,2 @@
PrintLn(Ord('a'));
PrintLn(Chr(97));

View file

@ -0,0 +1 @@
97P

View file

@ -0,0 +1,19 @@
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
aChar:Char;
aCode:Byte;
uChar:WideChar;
uCode:Word;
begin
aChar := Chr(97); Writeln(aChar);
aCode := Ord(aChar); Writeln(aCode);
uChar := WideChar(97); Writeln(uChar);
uCode := Ord(uChar); Writeln(uCode);
Readln;
end.

View file

@ -0,0 +1,4 @@
proc nonrec main() void:
writeln(pretend(97, char)); /* prints "a" */
writeln(pretend('a', byte)); /* prints 97 */
corp

View file

@ -0,0 +1,2 @@
print('a'.Order())
print(Char(97))

View file

@ -0,0 +1,5 @@
? 'a'.asInteger()
# value: 97
? <import:java.lang.makeCharacter>.asChar(97)
# value: 'a'

View file

@ -0,0 +1,2 @@
print strcode "a"
print strchar 97

View file

@ -0,0 +1,19 @@
module CharacterCodes {
@Inject Console console;
void run() {
for (Char char : ['\0', '\d', 'A', '$', '¢', '~', '˜']) {
// character to its integer value
UInt32 codepoint = char.codepoint;
// integer value back to its character value
Char fromCodePoint = codepoint.toChar(); // or: "new Char(codepoint)"
console.print($|Character {char.quoted()}:\
| Unicode codepoint={char.codepoint},\
| ASCII={char.ascii},\
| UTF8 bytes={char.utf8()},\
| char from codepoint={fromCodePoint.quoted()}
);
}
}
}

View file

@ -0,0 +1,28 @@
class
APPLICATION
inherit
ARGUMENTS
create
make
feature {NONE} -- Initialization
make
-- Run application.
local
c8: CHARACTER_8
c32: CHARACTER_32
do
c8 := '%/97/' -- using code value notation
c8 := '%/0x61/' -- same as above, but using hexadecimal literal
print(c8.natural_32_code) -- prints "97"
print(c8) -- prints the character "a"
c32 := 'a' -- using character literal
print(c32.natural_32_code) -- prints "97"
print(c32) -- prints "U+00000061"
--c8 := 'π' -- compile-time error (c8 does not have enough range)
c32 := 'π' -- assigns Unicode value 960
end
end

View file

@ -0,0 +1,9 @@
import extensions;
public program()
{
var ch := $97;
console.printLine:ch;
console.printLine(ch.toInt())
}

View file

@ -0,0 +1,4 @@
iex(1)> code = ?a
97
iex(2)> to_string([code])
"a"

View file

@ -0,0 +1,2 @@
(string-to-char "a") ;=> 97
(format "%c" 97) ;=> "a"

View file

@ -0,0 +1,4 @@
1> F = fun([X]) -> X end.
#Fun<erl_eval.6.13229925>
2> F("a").
97

View file

@ -0,0 +1,2 @@
3> $a.
97

View file

@ -0,0 +1,2 @@
printf(1,"%d\n", 'a') -- prints "97"
printf(1,"%s\n", 97) -- prints "a"

View file

@ -0,0 +1,4 @@
let c = 'A'
let n = 65
printfn "%d" (int c)
printfn "%c" (char n)

View file

@ -0,0 +1,2 @@
'A."
"65,

View file

@ -0,0 +1,4 @@
CHAR: katakana-letter-a .
"ア" first .
12450 1string print

View file

@ -0,0 +1,4 @@
fansh> 97.toChar
a
fansh> 'a'.toInt
97

View file

@ -0,0 +1,3 @@
char a
dup . \ 97
emit \ a

View file

@ -0,0 +1,2 @@
WRITE(*,*) ACHAR(97), IACHAR("a")
WRITE(*,*) CHAR(97), ICHAR("a")

View file

@ -0,0 +1,7 @@
' FreeBASIC v1.05.0 win64
Print "a - > "; Asc("a")
Print "98 -> "; Chr(98)
Print
Print "Press any key to exit the program"
Sleep
End

View file

@ -0,0 +1,5 @@
println[char["a"]] // prints 97
println[chars["a"]] // prints [97] (an array)
println[char[97]] // prints a
println[char["Frink rules!"]] // prints [70, 114, 105, 110, 107, 32, 114, 117, 108, 101, 115, 33]
println[[70, 114, 105, 110, 107, 32, 114, 117, 108, 101, 115, 33]] // prints "Frink rules!"

View file

@ -0,0 +1,4 @@
print "a -> "; ASC("a")
print "98 -> "; CHR$(98)
handleevents

View file

@ -0,0 +1,10 @@
Public Sub Form_Open()
Dim sChar As String
sChar = InputBox("Enter a character")
Print "Character " & sChar & " = ASCII " & Str(Asc(sChar))
sChar = InputBox("Enter a ASCII code")
Print "ASCII code " & sChar & " represents " & Chr(Val(sChar))
End

View file

@ -0,0 +1,5 @@
# Code must be in 0 .. 255.
CharInt(65);
# 'A'
IntChar('Z');
# 90

View file

@ -0,0 +1,2 @@
fmt.Println('a') // prints "97"
fmt.Println('π') // prints "960"

View file

@ -0,0 +1,12 @@
package main
import (
"fmt"
)
func main() {
// Given a character value in your language, print its code
fmt.Printf("%d\n", 'A') // prt 65
// Given a code, print out the corresponding character.
fmt.Printf("%c\n", 65) // prt A
}

View file

@ -0,0 +1,21 @@
package main
import "fmt"
func main() {
// yes, there is more concise syntax, but this makes
// the data types very clear.
var b byte = 'a'
var r rune = 'π'
var s string = "aπ"
fmt.Println(b, r, s)
fmt.Println("string cast to []rune:", []rune(s))
// A range loop over a string gives runes, not bytes
fmt.Print(" string range loop: ")
for _, c := range s {
fmt.Print(c, " ") // c is type rune
}
// We can also print the bytes of a string without an explicit loop
fmt.Printf("\n string bytes: % #x\n", s)
}

View file

@ -0,0 +1,3 @@
b := byte(97)
r := rune(960)
fmt.Printf("%c %c\n%c %c\n", 97, 960, b, r)

View file

@ -0,0 +1,3 @@
fmt.Println(string(97)) // prints "a"
fmt.Println(string(960)) // prints "π"
fmt.Println(string([]rune{97, 960})) // prints "aπ"

View file

@ -0,0 +1 @@
97[]+''+p

View file

@ -0,0 +1,4 @@
'a')\;p
'a'(\;p
'a'0=p
'a'{}/p

View file

@ -0,0 +1,2 @@
printf ("%d\n", ('a' as char) as int)
printf ("%c\n", 97)

View file

@ -0,0 +1,7 @@
import Data.Char
main = do
print (ord 'a') -- prints "97"
print (chr 97) -- prints "'a'"
print (ord 'π') -- prints "960"
print (chr 960) -- prints "'\960'"

View file

@ -0,0 +1 @@
WRITE(Messagebox) ICHAR('a'), CHAR(97)

View file

@ -0,0 +1,2 @@
Print("%d\n", 'a'); /* prints "97" */
Print("%c\n", 97); /* prints "a" */

View file

@ -0,0 +1,6 @@
|%
++ enc
|= char=@t `@ud`char
++ dec
|= code=@ud `@t`code
--

View file

@ -0,0 +1,4 @@
software {
print(number('a'))
print(text([97]))
}

View file

@ -0,0 +1,2 @@
100 PRINT ORD("A")
110 PRINT CHR$(65)

View file

@ -0,0 +1,6 @@
procedure main(arglist)
if *arglist > 0 then L := arglist else L := [97, "a"]
every x := !L do
write(x, " ==> ", char(integer(x)) | ord(x) ) # char produces a character, ord produces a number
end

View file

@ -0,0 +1,5 @@
"a" at(0) println // --> 97
97 asCharacter println // --> a
"π" at(0) println // --> 960
960 asCharacter println // --> π

View file

@ -0,0 +1,5 @@
4 u: 97 98 99 9786
abc☺
3 u: 7 u: 'abc☺'
97 98 99 9786

View file

@ -0,0 +1,2 @@
3 u: 'abc☺'
97 98 99 226 152 186

View file

@ -0,0 +1,4 @@
97 98 99{a.
abc
a.i.'abc'
97 98 99

View file

@ -0,0 +1 @@
(int) 'a'

View file

@ -0,0 +1 @@
(int) '\u0061'

View file

@ -0,0 +1 @@
(char) 97

View file

@ -0,0 +1 @@
Character.digit('1', 10)

View file

@ -0,0 +1 @@
Character.forDigit(1, 10)

View file

@ -0,0 +1,2 @@
console.log('a'.charCodeAt(0)); // prints "97"
console.log(String.fromCharCode(97)); // prints "a"

Some files were not shown because too many files have changed in this diff Show more