This is what we developers call clever code. Clever code is typically:
1. fast
2. concise
3. correct when written
4. almost impenetrable, and thus difficult to amend
You'll need to understand what the code is doing.
The code is applying the transformation described here:
http://www.w3schools.com/tags/ref_urlencode.asp
You need to undertand the ASCII table and the relationship between the characters:
http://www.asciitable.com/index/asciifull.gif
The expression:
(what[0] - '0'))
returns the integer value of a character in the range 0-9.
The expression:
((what[0] & 0xdf) - 'A')+10
returns the integer value of a hex character in the range A-F or a-f. The 0xDF mask is used to convert 'a' to 'A'. Like the answers post said, toupper could be used, but this is more consice once you know what it's doing.
So:
(what[0] >= 'A' ? ((what[0] & 0xdf) - 'A')+10 : (what[0] - '0'))
converts each hex character to a hex digit.
Mulplying by 16 shifts the digit over because we're dealing with base 16.
x2c
converts a hex 2 character string to decimal
unescape_url
edits, in place, the URL string passed in as replace escape sequences with their correct characters.