Newbie question converting char to ascii value

Paul Johnston paul.a.johnston@REDACTED
Fri Jun 5 17:45:19 CEST 2009


Hi

 

I want to take a character store it in a variable and then get it's
ascii value.

I know 

1> $a.

97

 

But want something like

 

2> Letter = a.

a

3> $Letter.

* 1: syntax error before: etter

3>

 

I could do it 

 

char_to_ascii(Letter) ->

            case Letter of 

                        a -> 97;

                        b -> 98;

                        ...

            end.

 

 

But that would be silly :-)

 

Cheers Paul

 

Paul Johnston

Humanities ICT (Infrastructure)

Samuel Alexander Building

Room W1.19

 

e-mail Paul.Johnston@REDACTED

web http://web-1.humanities.manchester.ac.uk/prjs/mcasspj/

 



More information about the erlang-questions mailing list