feat: add find_ascii_non_printable function to identify non-printable ASCII characters

This commit is contained in:
Bakyt Niiazaliev 2025-07-06 01:37:11 +07:00
parent 5653fa0708
commit c955f92af9
2 changed files with 7 additions and 0 deletions

View File

@ -174,3 +174,4 @@ def quote(string: str, safe: str) -> str:
"""
def unquote(value: str) -> str: ...
def find_ascii_non_printable(s: str) -> typing.Optional[int]: ...

View File

@ -71,6 +71,12 @@ pub fn quote(string: &str, safe: &str) -> String {
result
}
#[pyfunction]
pub fn find_ascii_non_printable(s: &str) -> Option<usize> {
s.chars()
.position(|c| c.is_ascii() && !c.is_ascii_graphic() && c != ' ')
}
pub(crate) trait PercentEncoded {
fn percent_encoded(&self, safe: &str) -> String;
}