

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.




message "enter a letter: ";
string a;
a := readstring;
message decimal (ASCII a); % writes the decimal number of the first character
                           % of the string a
message "enter a number: ";
num := scantokens readstring;
message char num;   % num can be anything between 0 and 255; what will be seen
                    % on output depends on the encoding used by the "terminal"; e.g.
                    % any code beyond 127 when UTF-8 encoding is in use will give
                    % a bad encoding; e.g. to see correctly an "è", we should write
message char10;  % (this add a newline...)
message char hex"c3" & char hex"a8";  % since C3 A8 is the UTF-8 encoding for "è"
end