Character codes: Difference between revisions

Content added Content deleted
(added Fortran)
Line 145: Line 145:
In Ruby currently characters are usually represented directly as their integer character code. Ruby has a syntax for "character literal" which evaluates directly to the integer code: <code>?a</code> evaluates to the integer 97. Subscripting a string also gives just the integer code for the character.
In Ruby currently characters are usually represented directly as their integer character code. Ruby has a syntax for "character literal" which evaluates directly to the integer code: <code>?a</code> evaluates to the integer 97. Subscripting a string also gives just the integer code for the character.


<ruby>print ?a # prints "97"
<ruby>print ?a, "\n" # prints "97"
print 'a'[0] # prints "97"
print 'a'[0], "\n" # prints "97"
print 97.chr # prints "a"; "91.chr" returns a string of length 1</ruby>
print 97.chr, "\n" # prints "a"; "91.chr" returns a string of length 1</ruby>


=={{header|Scheme}}==
=={{header|Scheme}}==