// blkid encodes certain tags in a safe encoding that hex-escapes "unsafe"
// characters. This is not a complete implementation and panics when given
// non-ASCII input. See note above: this could be replaced with libblkid
// directly if the need arises.
blkid encodes certain tags in a safe encoding that hex-escapes "unsafe"
characters. This is not a complete implementation and panics when given
non-ASCII input. See note above: this could be replaced with libblkid
directly if the need arises.
blkid encodes certain tags in a safe encoding that hex - escapes " unsafe " characters . This is not a complete implementation and panics when given non - ASCII input . See note above : this could be replaced with libblkid directly if the need arises .
fn blkid_encode_string<S: AsRef<str>>(s: S) -> String {
    if s.as_ref().chars().any(|ch| !ch.is_ascii()) {
        unimplemented!("this version of blkid_encode_string only supports ASCII");
    }
    let mut encoded = String::with_capacity(s.as_ref().len());
    for ch in s.as_ref().chars() {
        if ch.is_ascii_alphanumeric() {
            encoded.push(ch);
            continue;
        }
        encoded.push_str(format!("\\x{:x}", ch as u8).as_str());
    }
    encoded
}
fn blkid_encode_string < S : AsRef < str > > ( s : S ) -> String { if s . as_ref ( ) . chars ( ) . any ( | ch | ! ch . is_ascii ( ) ) { unimplemented ! ( " " ) ; } let mut encoded = String :: with_capacity ( s . as_ref ( ) . len ( ) ) ; for ch in s . as_ref ( ) . chars ( ) { if ch . is_ascii_alphanumeric ( ) { encoded . push ( ch ) ; continue ; } encoded . push_str ( format ! ( " \\ " ch as u8 ) . as_str ( ) ) ; } encoded }
blkid encodes certain tags in a safe encoding that hex-escapes "unsafe"
characters.
blkid encodes certain tags in a safe encoding that hex - escapes " unsafe " characters .
s
S