Skip to main content

decode_sjis

Function decode_sjis 

Source
pub fn decode_sjis(input: &[u8]) -> Result<String, DecodeError>
Expand description

Decode a Shift_JIS byte slice into UTF-8 (NFC normalisation is applied by the caller after decoding).

§Errors

Returns DecodeError::ShiftJisInvalid if encoding_rs reports a malformed byte sequence. Lossy replacement is deliberately not offered — callers need to know when they’re looking at corrupted source material rather than silently absorbing the damage.

Allocates a fresh String per call. For workloads that decode many documents in succession, prefer decode_sjis_into with a reusable buffer to avoid the per-call allocation.