Most people know atoi() - it's been in C since before it was ANSI C... but here's a little Objective-C nugget from some sample code that was sent to "help" Joseph H. implement a client for a web API.


-(char) atoi:(char) a{
    if (a >= '0' && a <= '9') {
        return a - '0';
    } else if (a >= 'a' && a <= 'z') {
        return a - 'a' + 10;
    } else if (a >= 'A' && a <= 'Z') {
        return a - 'A' + 10;
    } else {
        return 0;
    }
}

According to Joseph, for what it's worth (and because it actually adds to the mystery of why this code even exists), this code was usually passed a Unichar.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!