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.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
//! EBCDIC, which is not in the Encoding Standard.//!//! It is a separate type on purpose. The standard is a closed list, and//! `Encoding.fromLabel` refuses everything outside it, because a label that a//! server and a client resolve differently is an attack rather than a//! feature. Putting EBCDIC into `Encoding` would either give that up or leave//! a member of the type that `fromLabel` has to special-case, so it lives//! here instead: reachable only by naming it in code, never by a string off a//! header. There is no `fromLabel` here at all, and that is the point.//!//! What it shares with the rest of the library is everything below the type://! `Decoder` and `Encoder` drive it through the same loop, with the same//! error modes and the same streaming behaviour, and the tables come out of//! the same generator.
const std = @import("std");
/// The EBCDIC code pages with a complete, authoritative mapping published by/// Unicode.org. There are many more in the wild -- IBM assigned hundreds --/// and adding one is a matter of a mapping file in `data/` and a line in the/// generator, provided the mapping comes from somewhere citable.pub const CodePage = enum { /// US and Canada. What "EBCDIC" usually means when nothing else is said. cp037, /// International, the one with the fuller Latin-1 repertoire. Also called /// the "International #5" or Latin-1 EBCDIC page. cp500, /// Greek. cp875, /// Turkish. cp1026,
/// The IBM code page number this is, as text. pub fn name(self: CodePage) []const u8 { return switch (self) { .cp037 => "IBM037", .cp500 => "IBM500", .cp875 => "IBM875", .cp1026 => "IBM1026", }; }};
test "every code page has a name" { for (std.enums.values(CodePage)) |code_page| { try std.testing.expect(code_page.name().len > 0); }}