Skip to main content

decode_sjis_into

Function decode_sjis_into 

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

Decode a Shift_JIS byte slice into the caller-owned dst buffer.

Pre-sizes dst exactly via encoding_rs::Decoder::max_utf8_buffer_length_without_replacement so the decode inner loop does no growth-realloc. The buffer is not cleared first — callers that want a fresh decode should dst.clear() before calling. This is intentional so the same buffer can be reused across many decodes in a thread-local / per-worker pool without paying the allocator per iteration.

Strict — same error contract as decode_sjis. Bypasses encoding_rs’s public decode shape, which always allocates a worst-case-sized String internally and Cow::into_owneds the result; this entry point goes straight through the Decoder::decode_to_string_without_replacement API the bench pipeline needs.

§Errors

Returns DecodeError::ShiftJisInvalid on malformed input or if the encoder reports overflow (which max_utf8_buffer_length_… should make unreachable, but is still surfaced rather than silently truncated).