Character codes: Difference between revisions

Content added Content deleted
(Add Draco)
(Replace println() with print(); replace output "syntaxhighlight" tag with "pre" tag)
Line 852: Line 852:
Char fromCodePoint = codepoint.toChar(); // or: "new Char(codepoint)"
Char fromCodePoint = codepoint.toChar(); // or: "new Char(codepoint)"


console.println($|Character {char.quoted()}:\
console.print($|Character {char.quoted()}:\
| Unicode codepoint={char.codepoint},\
| Unicode codepoint={char.codepoint},\
| ASCII={char.ascii},\
| ASCII={char.ascii},\
| UTF8 bytes={char.utf8()}\
| UTF8 bytes={char.utf8()},\
| char from codepoint={fromCodePoint.quoted()}
| char from codepoint={fromCodePoint.quoted()}
);
);
}
}
}
}
Line 863: Line 863:
</syntaxhighlight>
</syntaxhighlight>


{{out}}
Resulting output:
<pre>
<syntaxhighlight lang="text">
Character '\0': Unicode codepoint=0, ASCII=True, UTF8 bytes=0x00 char from codepoint='\0'
Character '\0': Unicode codepoint=0, ASCII=True, UTF8 bytes=0x00, char from codepoint='\0'
Character '\d': Unicode codepoint=127, ASCII=True, UTF8 bytes=0x7F char from codepoint='\d'
Character '\d': Unicode codepoint=127, ASCII=True, UTF8 bytes=0x7F, char from codepoint='\d'
Character 'A': Unicode codepoint=65, ASCII=True, UTF8 bytes=0x41 char from codepoint='A'
Character 'A': Unicode codepoint=65, ASCII=True, UTF8 bytes=0x41, char from codepoint='A'
Character '$': Unicode codepoint=36, ASCII=True, UTF8 bytes=0x24 char from codepoint='$'
Character '$': Unicode codepoint=36, ASCII=True, UTF8 bytes=0x24, char from codepoint='$'
Character '¢': Unicode codepoint=162, ASCII=False, UTF8 bytes=0xC2A2 char from codepoint='¢'
Character '¢': Unicode codepoint=162, ASCII=False, UTF8 bytes=0xC2A2, char from codepoint='¢'
Character '~': Unicode codepoint=126, ASCII=True, UTF8 bytes=0x7E char from codepoint='~'
Character '~': Unicode codepoint=126, ASCII=True, UTF8 bytes=0x7E, char from codepoint='~'
Character '˜': Unicode codepoint=732, ASCII=False, UTF8 bytes=0xCB9C char from codepoint='˜'
Character '˜': Unicode codepoint=732, ASCII=False, UTF8 bytes=0xCB9C, char from codepoint='˜'
</pre>
</syntaxhighlight>


=={{header|Eiffel}}==
=={{header|Eiffel}}==