Is there an easy way in javascript to only escape certain ranges of control characters?
Specifically, I want to escape just the ranges “\x00-\x1f” and “\x7f-\xff” (control and high-bit characters). I need to escape only those characters before calculating a hash that is then sent to an API. The standard functions like encodeURI() and escape() escape too much.
Basically, I need to match the functionality of perl’s uri_escape($text,”\x00-\x1f\x7f-\xff”) .
1 Answer