Correctly handle the option 0x or 0X prefix for hexadecimal numberx (%x/%X)

I'm sorry for submitting so many small pull requests... Should I bundle these small fixes next time?
This pull request fixes #1632.