Return ASCII value as uint

okibi okibi at ratedo.com
Tue May 8 11:11:47 PDT 2007


John Ohno Wrote:

> Jarrett Billingsley Wrote:
> 
> > "okibi" <okibi at ratedo.com> wrote in message 
> > news:f1q8ne$3147$1 at digitalmars.com...
> > > That function contains the i variable from your function. Is there a 
> > > simple function, or should I use a cast?
> > 
> > Just cast it.  chars are just integers; you can freely cast between 
> > characters and integers. 
> > 
> > 
> 
> A good general template function (will work for anything that can be explicity casted to uint, including chars, doubles, and pointers):
> 
> uint toUint!(T)(T c) {
>         return (cast(uint)c);
> }

Well, that doesn't compile. Is the ! needed? Anyways, if I pass an "s" to that, it should return the ASCII value (115 I think), right?



More information about the Digitalmars-d-learn mailing list