=htc Fix handling of non-BMP characters in URI encoding/decoding

Closes #16014 by porting (improved versions) of these spray PRs:

- https://github.com/spray/spray/pull/855
- https://github.com/spray/spray/pull/856
Doesn't matter here, since we are only shifting 7 bits and comparing to zero.
Could have done `& 0x80 == 0` as well but that would have been 2 characters longer... :)