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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
//! Korean encodings that are not in the Encoding Standard.//!//! The standard has one Korean encoding, and it calls it EUC-KR, but what it//! defines is Windows code page 949: KS X 1001 *plus* the Unified Hangul Code,//! which squeezes the 8,822 syllables KS X 1001 left out into the byte ranges//! EUC leaves free. That is what the web sends, and it is `Encoding.euc_kr`.//! The two encodings here are the other ways Korean text was written down://!//! * **Wansung** (완성형, "precomposed") is KS X 1001 in its EUC form, with//! nothing added -- what RFC 1557 and the IANA registration of `EUC-KR`//! actually describe. It has codes for 2,350 Hangul syllables, and spells//! the rest out in eight bytes, as KS X 1001 defines.//! * **Johab** (조합형, "combining") is KS X 1001 Annex 3, Windows code page//! 1361. Hangul is not looked up in a table but spelled out: one bit, then//! five each for the initial consonant, the vowel and the final consonant,//! so all 11,172 modern syllables have a code. The symbols and Hanja of KS//! X 1001 are moved by arithmetic into the byte ranges the Hangul leave//! free.//!//! Both are separate from `Encoding` for the reason EBCDIC is: the standard's//! list is closed, and `Encoding.fromLabel` refusing everything outside it is//! what stops a label off a header choosing an encoding nobody vetted. These//! are reached by naming them in code, and there is no `fromLabel` here.//! Below the type they share everything with the rest of the library -- the//! same `Decoder` and `Encoder`, error modes and streaming -- and they need no//! tables of their own: KS X 1001 is the part of the standard's euc-kr index//! that sits in rows and columns 0xA1 to 0xFE, and both read it from there.
const std = @import("std");
pub const Korean = enum { /// KS X 1001 in EUC form, without the Unified Hangul Code extensions. wansung, /// KS X 1001 Annex 3, Windows code page 1361. johab,
/// What the encoding is usually called. pub fn name(self: Korean) []const u8 { return switch (self) { .wansung => "Wansung", .johab => "Johab", }; }};
test "every Korean encoding has a name" { for (std.enums.values(Korean)) |korean| { try std.testing.expect(korean.name().len > 0); }}