20 lines
722 B
Text
20 lines
722 B
Text
|
|
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()}
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|