Return ASCII value as uint

okibi okibi at ratedo.com
Tue May 8 09:32:46 PDT 2007


Alexander Panek Wrote:

> On Tue, 08 May 2007 11:27:40 -0400
> okibi <okibi at ratedo.com> wrote:
> 
> > Hey,
> > 
> > I was wondering if D has a simple function to return the ASCII value
> > of a character as a uint, much like ord() does in php.
> > 
> > Thanks!
> 
> Shouldn't a cast be sufficiant?
> 
> char c = 'a';
> uint i = cast(uint)c;

Yes, a cast would work, however I was wondering if there was an actual function that I could use to grab the value while passing it to another function, specifically this function:

saveItem.addAccelerator("activate",accelGroup,i,GdkModifierType.CONTROL_MASK,accelFlags);

That function contains the i variable from your function. Is there a simple function, or should I use a cast?


More information about the Digitalmars-d-learn mailing list