Is there a function available in C to easily lookup the hex value for an ascii char? I.e. If I wanted to encode so called 'special' chars to their hex values as with URLs;

so: "hello world" becomes "hello%20world"

or would I have to create my own switch-case statement for checking current char and print it to a string such as:

Code:
...
/* loop through string, until at end of string */
/* code to read current char in string */
...
switch currentChar{
  case ' ' : sprintf(str, "%20", null); break;
  case '%' : sprintf(str, "%25", null); break;
  ...
  default: return 1; /* ERROR! - should never be! */
}
or maybe even a few iteration statements to find the special chars that require encoding!