gix_filter/worktree/
encoding.rsuse bstr::BStr;
use encoding_rs::Encoding;
pub mod for_label {
use bstr::BString;
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("An encoding named '{name}' is not known")]
Unknown { name: BString },
}
}
pub fn for_label<'a>(label: impl Into<&'a BStr>) -> Result<&'static Encoding, for_label::Error> {
let mut label = label.into();
if label == "latin-1" {
label = "ISO-8859-1".into();
}
let enc = Encoding::for_label(label.as_ref()).ok_or_else(|| for_label::Error::Unknown { name: label.into() })?;
Ok(enc)
}