Return ASCII value as uint

John Ohno john.ohno at gmail.com
Tue May 8 09:49:36 PDT 2007


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);
}


More information about the Digitalmars-d-learn mailing list