[Issue 5543] to!int to see a char as a single-char string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 21 08:04:21 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=5543



--- Comment #12 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-12-21 08:04:19 PST ---
(In reply to comment #9)
> int numericValue(dchar c) @safe pure nothrow

What about int->dchar?

We could call it toNumericChar or something, but it would probably have to
throw on invalid input? Or can we also return -1? E.g.

char toNumericChar(int i) @safe pure nothrow
{
    return cast(char)((0 <= i && i <= 9) ? (i + '0') : -1);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list