Something went wrong. Try again.
Converting between UTF-8 and legacy character encodings, as the WHATWG Encoding Standard and glibc's iconv define them.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
//! replacement, § 14.1.//!//! Not an encoding: a way of refusing to be one. ISO-2022-KR, ISO-2022-CN and//! HZ-GB-2312 are all labels for it, because they let an attacker write bytes//! that a server reading them as one encoding and a client reading them as//! another disagree about -- the client seeing markup where the server saw//! text. Decoding the whole input as a single U+FFFD closes that off without//! having to make the label an error.//!//! It has no encoder. `Encoding.outputEncoding` sends it to UTF-8.
const codec = @import("../codec.zig");
const ByteQueue = codec.ByteQueue;const Decoded = codec.Decoded;
pub const Decoder = struct { /// One error for the whole input, however long the input is. error_returned: bool = false,
pub fn handle(self: *Decoder, _: *ByteQueue, byte: ?u8) Decoded { if (byte == null) return .finished; if (!self.error_returned) { self.error_returned = true; return .failure; } return .finished; }};