Skip to main content

decode_utf8_into

Function decode_utf8_into 

Source
pub fn decode_utf8_into<'b>(
    input: &[u8],
    out: &'b mut [u8],
) -> Result<&'b str, ParseError>
Expand description

As decode_into, and the decoded bytes must be UTF-8 (overlong forms and surrogates refused).

§Errors

ErrorKind::InvalidUtf8, and as decode_into. Nothing is written on error.

§Examples

use parse_net::{pct::decode_utf8_into, ErrorKind};

let mut buf = [0u8; 8];
assert_eq!(decode_utf8_into(b"%E2%82%AC", &mut buf)?, "\u{20ac}");
assert_eq!(decode_utf8_into(b"%C0%AF", &mut buf).unwrap_err().kind(), ErrorKind::InvalidUtf8);