Character codes: Difference between revisions

Add Ecstasy example
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(Add Ecstasy example)
Line 829:
<syntaxhighlight lang="text">print strcode "a"
print strchar 97</syntaxhighlight>
 
=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
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.println($|Character {char.quoted()}:\
| Unicode codepoint={char.codepoint},\
| ASCII={char.ascii},\
| UTF8 bytes={char.utf8()}\
| char from codepoint={fromCodePoint.quoted()}
);
}
}
}
</syntaxhighlight>
 
Resulting output:
<syntaxhighlight lang="text">
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 '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=162, ASCII=False, UTF8 bytes=0xC2A2 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='˜'
</syntaxhighlight>
 
=={{header|Eiffel}}==
All characters are of the type CHARACTER_8 (ASCII encoding) or CHARACTER_32 (Unicode encoding). CHARACTER is a synonym for either of these two (depending on the compiler option). Characters can be assigned using character literals (a single character enclosed in single quotes) or code value notation (of the form '%/value/' where value is an integer literal of any of the recognized forms).
162

edits