Get the BOM bytes for this encoding, if applicable. # Returns The BOM bytes, or an empty slice for encodings without BOM.
(&self)
| 179 | /// |
| 180 | /// The BOM bytes, or an empty slice for encodings without BOM. |
| 181 | pub fn bom(&self) -> &'static [u8] { |
| 182 | match self { |
| 183 | Encoding::Utf8 => &[], // UTF-8 BOM is optional, we don't add it |
| 184 | Encoding::Utf16Le => &[0xFF, 0xFE], |
| 185 | Encoding::Utf16Be => &[0xFE, 0xFF], |
| 186 | Encoding::Latin1 => &[], |
| 187 | Encoding::Binary => &[], |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /// Get the canonical name of this encoding. |
| 192 | /// |