[erlang-questions] Newbie question converting char to ascii value

David Mercer dmercer@REDACTED
Fri Jun 5 18:48:14 CEST 2009


Try hd(atom_to_list(a)).

> -----Original Message-----
> From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On
> Behalf Of Paul Johnston
> Sent: Friday, June 05, 2009 10:45 AM
> To: erlang-questions@REDACTED
> Subject: [erlang-questions] Newbie question converting char to ascii value
> 
> 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