pub fn encode(self, input: &str) -> (Cow<[u8]>, bool) {
        match self {
            Charset::Ascii => {
                let (out, _, errors) = encoding_rs::WINDOWS_1252.encode(input);
                (out, errors)
            }
            Charset::Utf7 | Charset::Unknown8Bit => (Cow::Borrowed(input.as_bytes()), false),
            Charset::Encoding(encoding) => {
                let (out, _, errors) = encoding.encode(input);
                (out, errors)
            }
        }
    }
// Convenience function for encoding strings, taking into account
// that they might be unknown-8bit (ie: have surrogate-escaped bytes)
Convenience function for encoding strings, taking into account
that they might be unknown-8bit
Convenience function for encoding strings taking into account that they might be unknown - 8bit
pub fn encode(self, input: &str) -> (Cow<[u8]>, bool) {
        match self {
            Charset::Ascii => {
                let (out, _, errors) = encoding_rs::WINDOWS_1252.encode(input);
                (out, errors)
            }
            Charset::Utf7 | Charset::Unknown8Bit => (Cow::Borrowed(input.as_bytes()), false),
            Charset::Encoding(encoding) => {
                let (out, _, errors) = encoding.encode(input);
                (out, errors)
            }
        }
    }
pub fn encode ( self , input : & str ) -> ( Cow < [ u8 ] > , bool ) { match self { Charset :: Ascii => { let ( out , _ , errors ) = encoding_rs :: WINDOWS_1252 . encode ( input ) ; ( out , errors ) } Charset :: Utf7 | Charset :: Unknown8Bit => ( Cow :: Borrowed ( input . as_bytes ( ) ) , false ) , Charset :: Encoding ( encoding ) => { let ( out , _ , errors ) = encoding . encode ( input ) ; ( out , errors ) } } }
Convenience function for encoding strings, taking into account
that they might be unknown-8bit (ie: have surrogate-escaped bytes)
Convenience function for encoding strings taking into account that they might be unknown - 8bit ( ie : have surrogate - escaped bytes )
self
input
&str
self
input
&str