Character codes: Difference between revisions

Content deleted Content added
Added an ActionScript version.
Line 3: Line 3:
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses). For 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.
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses). For 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.


=={{header|ActionScript}}==
In ActionScript, you cannot take the character code of a character directly. Instead you must create a string and call charCodeAt with the character's position in the string as a parameter.
<lang ActionScipt>trace(String.fromCharCode(97)); //prints 'a'
trace("a".charCodeAt(0));//prints '97'</lang>
=={{header|Ada}}==
=={{header|Ada}}==
<lang ada>with Ada.Text_IO; use Ada.Text_IO;
<lang ada>with Ada.Text_IO; use Ada.Text_IO;