Skip to main content

decode_bytes_to_string

Function decode_bytes_to_string 

Source
pub fn decode_bytes_to_string(bytes: &[u8]) -> String
Expand description

Decode a byte buffer to a String, trying UTF-8 first, then Latin-1.

Latin-1 (ISO-8859-1) maps bytes 0x00-0xFF directly to Unicode U+0000-U+00FF, so it can decode any byte sequence. This matches Python ScanCode’s use of UnicodeDammit which auto-detects encoding with Latin-1 as fallback.