unicode-charname 0.1.0

This crate provides functions for retrieving Unicode character name properties as described in Unicode Standard Annex #44.
Documentation
#![allow(dead_code)]
// This is adapted from Unicode 13.0, 3.12.

#[cfg(not(feature = "std"))]
use alloc::string::String;

const S_BASE: u32 = 0xAC00;
const L_BASE: u32 = 0x1100;
const V_BASE: u32 = 0x1161;
const T_BASE: u32 = 0x11A7;
const L_COUNT: u32 = 19;
const V_COUNT: u32 = 21;
const T_COUNT: u32 = 28;
const N_COUNT: u32 = V_COUNT * T_COUNT; // 588
const S_COUNT: u32 = L_COUNT * N_COUNT; // 11172

const JAMO_L_TABLE: &[&'static str] = &[
    "G", "GG", "N", "D", "DD", "R", "M", "B", "BB", "S", "SS", "", "J", "JJ", "C", "K", "T", "P",
    "H",
];

const JAMO_V_TABLE: &[&'static str] = &[
    "A", "AE", "YA", "YAE", "EO", "E", "YEO", "YE", "O", "WA", "WAE", "OE", "YO", "U", "WEO", "WE",
    "WI", "YU", "EU", "YI", "I",
];

const JAMO_T_TABLE: &[&'static str] = &[
    "", "G", "GG", "GS", "N", "NJ", "NH", "D", "L", "LG", "LM", "LB", "LS", "LT", "LP", "LH", "M",
    "B", "BS", "S", "SS", "NG", "J", "C", "K", "T", "P", "H",
];

pub(crate) fn hangul_name(s: u32) -> String {
    let s_index = s - S_BASE;
    assert!(s_index < S_COUNT);
    let l_index = s_index / N_COUNT;
    let v_index = (s_index % N_COUNT) / T_COUNT;
    let t_index = s_index % T_COUNT;
    alloc::format!(
        "HANGUL SYLLABLE {}{}{}",
        JAMO_L_TABLE[l_index as usize],
        JAMO_V_TABLE[v_index as usize],
        JAMO_T_TABLE[t_index as usize]
    )
}