RosettaCodeData/Task/Character-codes/Ecstasy/character-codes.ecstasy

20 lines
722 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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()}
);
}
}
}