Open tustvold opened 2 years ago
Background
Sometimes you wish to take a string and verify that it has been correctly escaped. Particularly if % is in the escaped character list, you can't just percent-encode the string to be safe, as this will change the string.
%
This is exactly the case on https://github.com/apache/arrow-rs/pull/2356 where I wanted an API to check if a given byte is "legal".
Proposed Solution
AsciiSet::should_percent_encode would be perfect, however, it is private. I therefore hacked around this by doing
AsciiSet::should_percent_encode
byte.is_ascii() || percent_encode(&[c], <AsciiSet>).next().unwrap().len() != 1
But it would be nicer if the method on AsciiSet were exposed.
AsciiSet
Background
Sometimes you wish to take a string and verify that it has been correctly escaped. Particularly if
%
is in the escaped character list, you can't just percent-encode the string to be safe, as this will change the string.This is exactly the case on https://github.com/apache/arrow-rs/pull/2356 where I wanted an API to check if a given byte is "legal".
Proposed Solution
AsciiSet::should_percent_encode
would be perfect, however, it is private. I therefore hacked around this by doingBut it would be nicer if the method on
AsciiSet
were exposed.