This is not particularly resilient or efficient. Take a look at https://github.com/vmg/houdini/blob/master/houdini_uri_u.c#L36 for a proper unescaping routine. You need to manage the case where the escape sequence is not valid. Also, use the magical `((c | 32) % 39 - 9)` macro instead of all those comparisons.