Skip to content

HTML Entity Encoder/Decoder — Java source

Encode text to HTML entities and decode entities back to text (named + numeric). UTF-8 safe, runs entirely in your browser, with a shareable link to your exact input.

This is the Java implementation — the same logic the interactive tool runs, in a shareable, citable form.

// =============================================================================
//  HtmlEntityEncoder.java — CosmoDev polyglot showcase port of the
//  `html-entity-encoder` tool
//  -----------------------------------------------------------------------------
//  Language : Java (17, standard library only)
//  Source:   ported from src/lib/htmlEntities.ts (the canonical, live
//             TypeScript lib); mirrors
//             src/tool-sources/html-entity-encoder/{python.py,rust.rs}
//  License  : display source — part of CosmoDev's polyglot tool pages
//             (dev.cosmolabs.org). Shown verbatim alongside the JS/TS/Go/Rust/
//             Python ports and the other language ports.
//  -----------------------------------------------------------------------------
//  HTML entity encode / decode — pure string transforms that never throw.
//  Encode escapes the five HTML-significant characters (& < > ' ") and can
//  optionally flatten every non-ASCII code point to a decimal numeric
//  reference. Decode resolves named (&amp;, &copy;, …), decimal (&#169;), and
//  hex (&#xA9;) references; unknown or malformed references pass through
//  whole.
//
//  Behavior matches the TypeScript lib exactly: same inputs yield identical
//  outputs, including the lone-surrogate and out-of-range guards (decode
//  never throws on bad input — unresolvable references are returned verbatim).
//
//  Encode iterates String.codePoints() (full scalar values), so an astral
//  character such as an emoji encodes as a single &#N; reference rather than
//  two surrogate halves. The reference scanner is hand-rolled (java.util
//  regex exists but a char scanner mirrors the Rust port and keeps the
//  snippet dependency-free).
//
//  The named-entity table is the full WHATWG HTML named-character-reference
//  set (2125 entries), generated from src/lib/htmlEntityTable.ts so the data
//  stays byte-identical to the canonical TypeScript lib.
// =============================================================================

package com.cosmolabs.cosmodev;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public final class HtmlEntityEncoder {

    private HtmlEntityEncoder() {}

    /** Encode options.
     *
     * <p>{@code ascii} — when true, every non-ASCII code point is also
     * emitted as a decimal numeric reference (e.g. © → {@code &#169;}), to
     * produce ASCII-safe output. When false (the default), only the five
     * HTML-significant characters are escaped. Pass {@code null} to
     * encodeHtml for the default. */
    public record EncodeOptions(boolean ascii) {
        public static final EncodeOptions DEFAULT = new EncodeOptions(false);
    }

    /** Escape the five HTML-significant characters.
     *
     * <p>A single-pass loop over code points: {@code &} is emitted as
     * {@code &amp;} and so on. (The Python port runs five sequential replaces
     * and must replace {@code &} first so its own output is never re-escaped
     * — matching on one code point at a time makes that ordering concern
     * moot.)
     *
     * <p>With {@code options.ascii()} set, every non-ASCII code point is
     * additionally rewritten to a decimal numeric reference. codePoints()
     * yields full scalar values, so an astral character such as an emoji
     * encodes as a single reference rather than two surrogate halves. */
    public static String encodeHtml(String text) {
        return encodeHtml(text, null);
    }

    public static String encodeHtml(String text, EncodeOptions options) {
        final boolean ascii = options != null && options.ascii();
        final StringBuilder out = new StringBuilder(text.length() + 16);
        text.codePoints().forEach(cp -> {
            switch (cp) {
                case '&' -> out.append("&amp;");
                case '<' -> out.append("&lt;");
                case '>' -> out.append("&gt;");
                case '\'' -> out.append("&apos;");
                case '"' -> out.append("&quot;");
                default -> {
                    if (ascii && cp > 0x7F) {
                        out.append("&#").append(cp).append(';');
                    } else {
                        out.appendCodePoint(cp);
                    }
                }
            }
        });
        return out.toString();
    }

    /** Decode every recognized reference in {@code text}. Unknown references
     * and stray ampersands are left exactly as they appear in the input.
     * Decode is total: it never throws on malformed or out-of-range input —
     * such references are returned verbatim. */
    public static String decodeHtml(String text) {
        final StringBuilder out = new StringBuilder(text.length());
        final int n = text.length();
        int i = 0;
        while (i < n) {
            if (text.charAt(i) == '&') {
                Reference ref = new Reference();
                if (parseReference(text, i, ref)) {
                    if (ref.resolved) {
                        out.append(ref.value);
                    } else {
                        out.append(text, i, ref.end);
                    }
                    i = ref.end;
                    continue;
                }
            }
            // No reference starts here: copy one UTF-16 unit and advance.
            // '&' can never appear inside a surrogate half, so unit-wise
            // copying never splits a pair.
            out.append(text.charAt(i));
            i++;
        }
        return out.toString();
    }

    /** The full WHATWG HTML named-character-reference table, name →
     * character. Generated from src/lib/htmlEntityTable.ts (2125 entries).
     * Do not edit by hand — regenerate from the canonical source. */
    private static final Map<String, String> HTML_ENTITY_TABLE;

    static {
        Map<String, String> m = new HashMap<>(2128);
        m.put("AElig", "Æ");
        m.put("AMP", "&");
        m.put("Aacute", "Á");
        m.put("Abreve", "Ă");
        m.put("Acirc", "Â");
        m.put("Acy", "А");
        m.put("Afr", "𝔄");
        m.put("Agrave", "À");
        m.put("Alpha", "Α");
        m.put("Amacr", "Ā");
        m.put("And", "⩓");
        m.put("Aogon", "Ą");
        m.put("Aopf", "𝔸");
        m.put("ApplyFunction", "⁡");
        m.put("Aring", "Å");
        m.put("Ascr", "𝒜");
        m.put("Assign", "≔");
        m.put("Atilde", "Ã");
        m.put("Auml", "Ä");
        m.put("Backslash", "∖");
        m.put("Barv", "⫧");
        m.put("Barwed", "⌆");
        m.put("Bcy", "Б");
        m.put("Because", "∵");
        m.put("Bernoullis", "ℬ");
        m.put("Beta", "Β");
        m.put("Bfr", "𝔅");
        m.put("Bopf", "𝔹");
        m.put("Breve", "˘");
        m.put("Bscr", "ℬ");
        m.put("Bumpeq", "≎");
        m.put("CHcy", "Ч");
        m.put("COPY", "©");
        m.put("Cacute", "Ć");
        m.put("Cap", "⋒");
        m.put("CapitalDifferentialD", "ⅅ");
        m.put("Cayleys", "ℭ");
        m.put("Ccaron", "Č");
        m.put("Ccedil", "Ç");
        m.put("Ccirc", "Ĉ");
        m.put("Cconint", "∰");
        m.put("Cdot", "Ċ");
        m.put("Cedilla", "¸");
        m.put("CenterDot", "·");
        m.put("Cfr", "ℭ");
        m.put("Chi", "Χ");
        m.put("CircleDot", "⊙");
        m.put("CircleMinus", "⊖");
        m.put("CirclePlus", "⊕");
        m.put("CircleTimes", "⊗");
        m.put("ClockwiseContourIntegral", "∲");
        m.put("CloseCurlyDoubleQuote", "”");
        m.put("CloseCurlyQuote", "’");
        m.put("Colon", "∷");
        m.put("Colone", "⩴");
        m.put("Congruent", "≡");
        m.put("Conint", "∯");
        m.put("ContourIntegral", "∮");
        m.put("Copf", "ℂ");
        m.put("Coproduct", "∐");
        m.put("CounterClockwiseContourIntegral", "∳");
        m.put("Cross", "⨯");
        m.put("Cscr", "𝒞");
        m.put("Cup", "⋓");
        m.put("CupCap", "≍");
        m.put("DD", "ⅅ");
        m.put("DDotrahd", "⤑");
        m.put("DJcy", "Ђ");
        m.put("DScy", "Ѕ");
        m.put("DZcy", "Џ");
        m.put("Dagger", "‡");
        m.put("Darr", "↡");
        m.put("Dashv", "⫤");
        m.put("Dcaron", "Ď");
        m.put("Dcy", "Д");
        m.put("Del", "∇");
        m.put("Delta", "Δ");
        m.put("Dfr", "𝔇");
        m.put("DiacriticalAcute", "´");
        m.put("DiacriticalDot", "˙");
        m.put("DiacriticalDoubleAcute", "˝");
        m.put("DiacriticalGrave", "`");
        m.put("DiacriticalTilde", "˜");
        m.put("Diamond", "⋄");
        m.put("DifferentialD", "ⅆ");
        m.put("Dopf", "𝔻");
        m.put("Dot", "¨");
        m.put("DotDot", "⃜");
        m.put("DotEqual", "≐");
        m.put("DoubleContourIntegral", "∯");
        m.put("DoubleDot", "¨");
        m.put("DoubleDownArrow", "⇓");
        m.put("DoubleLeftArrow", "⇐");
        m.put("DoubleLeftRightArrow", "⇔");
        m.put("DoubleLeftTee", "⫤");
        m.put("DoubleLongLeftArrow", "⟸");
        m.put("DoubleLongLeftRightArrow", "⟺");
        m.put("DoubleLongRightArrow", "⟹");
        m.put("DoubleRightArrow", "⇒");
        m.put("DoubleRightTee", "⊨");
        m.put("DoubleUpArrow", "⇑");
        m.put("DoubleUpDownArrow", "⇕");
        m.put("DoubleVerticalBar", "∥");
        m.put("DownArrow", "↓");
        m.put("DownArrowBar", "⤓");
        m.put("DownArrowUpArrow", "⇵");
        m.put("DownBreve", "̑");
        m.put("DownLeftRightVector", "⥐");
        m.put("DownLeftTeeVector", "⥞");
        m.put("DownLeftVector", "↽");
        m.put("DownLeftVectorBar", "⥖");
        m.put("DownRightTeeVector", "⥟");
        m.put("DownRightVector", "⇁");
        m.put("DownRightVectorBar", "⥗");
        m.put("DownTee", "⊤");
        m.put("DownTeeArrow", "↧");
        m.put("Downarrow", "⇓");
        m.put("Dscr", "𝒟");
        m.put("Dstrok", "Đ");
        m.put("ENG", "Ŋ");
        m.put("ETH", "Ð");
        m.put("Eacute", "É");
        m.put("Ecaron", "Ě");
        m.put("Ecirc", "Ê");
        m.put("Ecy", "Э");
        m.put("Edot", "Ė");
        m.put("Efr", "𝔈");
        m.put("Egrave", "È");
        m.put("Element", "∈");
        m.put("Emacr", "Ē");
        m.put("EmptySmallSquare", "◻");
        m.put("EmptyVerySmallSquare", "▫");
        m.put("Eogon", "Ę");
        m.put("Eopf", "𝔼");
        m.put("Epsilon", "Ε");
        m.put("Equal", "⩵");
        m.put("EqualTilde", "≂");
        m.put("Equilibrium", "⇌");
        m.put("Escr", "ℰ");
        m.put("Esim", "⩳");
        m.put("Eta", "Η");
        m.put("Euml", "Ë");
        m.put("Exists", "∃");
        m.put("ExponentialE", "ⅇ");
        m.put("Fcy", "Ф");
        m.put("Ffr", "𝔉");
        m.put("FilledSmallSquare", "◼");
        m.put("FilledVerySmallSquare", "▪");
        m.put("Fopf", "𝔽");
        m.put("ForAll", "∀");
        m.put("Fouriertrf", "ℱ");
        m.put("Fscr", "ℱ");
        m.put("GJcy", "Ѓ");
        m.put("GT", ">");
        m.put("Gamma", "Γ");
        m.put("Gammad", "Ϝ");
        m.put("Gbreve", "Ğ");
        m.put("Gcedil", "Ģ");
        m.put("Gcirc", "Ĝ");
        m.put("Gcy", "Г");
        m.put("Gdot", "Ġ");
        m.put("Gfr", "𝔊");
        m.put("Gg", "⋙");
        m.put("Gopf", "𝔾");
        m.put("GreaterEqual", "≥");
        m.put("GreaterEqualLess", "⋛");
        m.put("GreaterFullEqual", "≧");
        m.put("GreaterGreater", "⪢");
        m.put("GreaterLess", "≷");
        m.put("GreaterSlantEqual", "⩾");
        m.put("GreaterTilde", "≳");
        m.put("Gscr", "𝒢");
        m.put("Gt", "≫");
        m.put("HARDcy", "Ъ");
        m.put("Hacek", "ˇ");
        m.put("Hat", "^");
        m.put("Hcirc", "Ĥ");
        m.put("Hfr", "ℌ");
        m.put("HilbertSpace", "ℋ");
        m.put("Hopf", "ℍ");
        m.put("HorizontalLine", "─");
        m.put("Hscr", "ℋ");
        m.put("Hstrok", "Ħ");
        m.put("HumpDownHump", "≎");
        m.put("HumpEqual", "≏");
        m.put("IEcy", "Е");
        m.put("IJlig", "IJ");
        m.put("IOcy", "Ё");
        m.put("Iacute", "Í");
        m.put("Icirc", "Î");
        m.put("Icy", "И");
        m.put("Idot", "İ");
        m.put("Ifr", "ℑ");
        m.put("Igrave", "Ì");
        m.put("Im", "ℑ");
        m.put("Imacr", "Ī");
        m.put("ImaginaryI", "ⅈ");
        m.put("Implies", "⇒");
        m.put("Int", "∬");
        m.put("Integral", "∫");
        m.put("Intersection", "⋂");
        m.put("InvisibleComma", "⁣");
        m.put("InvisibleTimes", "⁢");
        m.put("Iogon", "Į");
        m.put("Iopf", "𝕀");
        m.put("Iota", "Ι");
        m.put("Iscr", "ℐ");
        m.put("Itilde", "Ĩ");
        m.put("Iukcy", "І");
        m.put("Iuml", "Ï");
        m.put("Jcirc", "Ĵ");
        m.put("Jcy", "Й");
        m.put("Jfr", "𝔍");
        m.put("Jopf", "𝕁");
        m.put("Jscr", "𝒥");
        m.put("Jsercy", "Ј");
        m.put("Jukcy", "Є");
        m.put("KHcy", "Х");
        m.put("KJcy", "Ќ");
        m.put("Kappa", "Κ");
        m.put("Kcedil", "Ķ");
        m.put("Kcy", "К");
        m.put("Kfr", "𝔎");
        m.put("Kopf", "𝕂");
        m.put("Kscr", "𝒦");
        m.put("LJcy", "Љ");
        m.put("LT", "<");
        m.put("Lacute", "Ĺ");
        m.put("Lambda", "Λ");
        m.put("Lang", "⟪");
        m.put("Laplacetrf", "ℒ");
        m.put("Larr", "↞");
        m.put("Lcaron", "Ľ");
        m.put("Lcedil", "Ļ");
        m.put("Lcy", "Л");
        m.put("LeftAngleBracket", "⟨");
        m.put("LeftArrow", "←");
        m.put("LeftArrowBar", "⇤");
        m.put("LeftArrowRightArrow", "⇆");
        m.put("LeftCeiling", "⌈");
        m.put("LeftDoubleBracket", "⟦");
        m.put("LeftDownTeeVector", "⥡");
        m.put("LeftDownVector", "⇃");
        m.put("LeftDownVectorBar", "⥙");
        m.put("LeftFloor", "⌊");
        m.put("LeftRightArrow", "↔");
        m.put("LeftRightVector", "⥎");
        m.put("LeftTee", "⊣");
        m.put("LeftTeeArrow", "↤");
        m.put("LeftTeeVector", "⥚");
        m.put("LeftTriangle", "⊲");
        m.put("LeftTriangleBar", "⧏");
        m.put("LeftTriangleEqual", "⊴");
        m.put("LeftUpDownVector", "⥑");
        m.put("LeftUpTeeVector", "⥠");
        m.put("LeftUpVector", "↿");
        m.put("LeftUpVectorBar", "⥘");
        m.put("LeftVector", "↼");
        m.put("LeftVectorBar", "⥒");
        m.put("Leftarrow", "⇐");
        m.put("Leftrightarrow", "⇔");
        m.put("LessEqualGreater", "⋚");
        m.put("LessFullEqual", "≦");
        m.put("LessGreater", "≶");
        m.put("LessLess", "⪡");
        m.put("LessSlantEqual", "⩽");
        m.put("LessTilde", "≲");
        m.put("Lfr", "𝔏");
        m.put("Ll", "⋘");
        m.put("Lleftarrow", "⇚");
        m.put("Lmidot", "Ŀ");
        m.put("LongLeftArrow", "⟵");
        m.put("LongLeftRightArrow", "⟷");
        m.put("LongRightArrow", "⟶");
        m.put("Longleftarrow", "⟸");
        m.put("Longleftrightarrow", "⟺");
        m.put("Longrightarrow", "⟹");
        m.put("Lopf", "𝕃");
        m.put("LowerLeftArrow", "↙");
        m.put("LowerRightArrow", "↘");
        m.put("Lscr", "ℒ");
        m.put("Lsh", "↰");
        m.put("Lstrok", "Ł");
        m.put("Lt", "≪");
        m.put("Map", "⤅");
        m.put("Mcy", "М");
        m.put("MediumSpace", " ");
        m.put("Mellintrf", "ℳ");
        m.put("Mfr", "𝔐");
        m.put("MinusPlus", "∓");
        m.put("Mopf", "𝕄");
        m.put("Mscr", "ℳ");
        m.put("Mu", "Μ");
        m.put("NJcy", "Њ");
        m.put("Nacute", "Ń");
        m.put("Ncaron", "Ň");
        m.put("Ncedil", "Ņ");
        m.put("Ncy", "Н");
        m.put("NegativeMediumSpace", "​");
        m.put("NegativeThickSpace", "​");
        m.put("NegativeThinSpace", "​");
        m.put("NegativeVeryThinSpace", "​");
        m.put("NestedGreaterGreater", "≫");
        m.put("NestedLessLess", "≪");
        m.put("NewLine", "\n");
        m.put("Nfr", "𝔑");
        m.put("NoBreak", "⁠");
        m.put("NonBreakingSpace", " ");
        m.put("Nopf", "ℕ");
        m.put("Not", "⫬");
        m.put("NotCongruent", "≢");
        m.put("NotCupCap", "≭");
        m.put("NotDoubleVerticalBar", "∦");
        m.put("NotElement", "∉");
        m.put("NotEqual", "≠");
        m.put("NotEqualTilde", "≂̸");
        m.put("NotExists", "∄");
        m.put("NotGreater", "≯");
        m.put("NotGreaterEqual", "≱");
        m.put("NotGreaterFullEqual", "≧̸");
        m.put("NotGreaterGreater", "≫̸");
        m.put("NotGreaterLess", "≹");
        m.put("NotGreaterSlantEqual", "⩾̸");
        m.put("NotGreaterTilde", "≵");
        m.put("NotHumpDownHump", "≎̸");
        m.put("NotHumpEqual", "≏̸");
        m.put("NotLeftTriangle", "⋪");
        m.put("NotLeftTriangleBar", "⧏̸");
        m.put("NotLeftTriangleEqual", "⋬");
        m.put("NotLess", "≮");
        m.put("NotLessEqual", "≰");
        m.put("NotLessGreater", "≸");
        m.put("NotLessLess", "≪̸");
        m.put("NotLessSlantEqual", "⩽̸");
        m.put("NotLessTilde", "≴");
        m.put("NotNestedGreaterGreater", "⪢̸");
        m.put("NotNestedLessLess", "⪡̸");
        m.put("NotPrecedes", "⊀");
        m.put("NotPrecedesEqual", "⪯̸");
        m.put("NotPrecedesSlantEqual", "⋠");
        m.put("NotReverseElement", "∌");
        m.put("NotRightTriangle", "⋫");
        m.put("NotRightTriangleBar", "⧐̸");
        m.put("NotRightTriangleEqual", "⋭");
        m.put("NotSquareSubset", "⊏̸");
        m.put("NotSquareSubsetEqual", "⋢");
        m.put("NotSquareSuperset", "⊐̸");
        m.put("NotSquareSupersetEqual", "⋣");
        m.put("NotSubset", "⊂⃒");
        m.put("NotSubsetEqual", "⊈");
        m.put("NotSucceeds", "⊁");
        m.put("NotSucceedsEqual", "⪰̸");
        m.put("NotSucceedsSlantEqual", "⋡");
        m.put("NotSucceedsTilde", "≿̸");
        m.put("NotSuperset", "⊃⃒");
        m.put("NotSupersetEqual", "⊉");
        m.put("NotTilde", "≁");
        m.put("NotTildeEqual", "≄");
        m.put("NotTildeFullEqual", "≇");
        m.put("NotTildeTilde", "≉");
        m.put("NotVerticalBar", "∤");
        m.put("Nscr", "𝒩");
        m.put("Ntilde", "Ñ");
        m.put("Nu", "Ν");
        m.put("OElig", "Œ");
        m.put("Oacute", "Ó");
        m.put("Ocirc", "Ô");
        m.put("Ocy", "О");
        m.put("Odblac", "Ő");
        m.put("Ofr", "𝔒");
        m.put("Ograve", "Ò");
        m.put("Omacr", "Ō");
        m.put("Omega", "Ω");
        m.put("Omicron", "Ο");
        m.put("Oopf", "𝕆");
        m.put("OpenCurlyDoubleQuote", "“");
        m.put("OpenCurlyQuote", "‘");
        m.put("Or", "⩔");
        m.put("Oscr", "𝒪");
        m.put("Oslash", "Ø");
        m.put("Otilde", "Õ");
        m.put("Otimes", "⨷");
        m.put("Ouml", "Ö");
        m.put("OverBar", "‾");
        m.put("OverBrace", "⏞");
        m.put("OverBracket", "⎴");
        m.put("OverParenthesis", "⏜");
        m.put("PartialD", "∂");
        m.put("Pcy", "П");
        m.put("Pfr", "𝔓");
        m.put("Phi", "Φ");
        m.put("Pi", "Π");
        m.put("PlusMinus", "±");
        m.put("Poincareplane", "ℌ");
        m.put("Popf", "ℙ");
        m.put("Pr", "⪻");
        m.put("Precedes", "≺");
        m.put("PrecedesEqual", "⪯");
        m.put("PrecedesSlantEqual", "≼");
        m.put("PrecedesTilde", "≾");
        m.put("Prime", "″");
        m.put("Product", "∏");
        m.put("Proportion", "∷");
        m.put("Proportional", "∝");
        m.put("Pscr", "𝒫");
        m.put("Psi", "Ψ");
        m.put("QUOT", "\"");
        m.put("Qfr", "𝔔");
        m.put("Qopf", "ℚ");
        m.put("Qscr", "𝒬");
        m.put("RBarr", "⤐");
        m.put("REG", "®");
        m.put("Racute", "Ŕ");
        m.put("Rang", "⟫");
        m.put("Rarr", "↠");
        m.put("Rarrtl", "⤖");
        m.put("Rcaron", "Ř");
        m.put("Rcedil", "Ŗ");
        m.put("Rcy", "Р");
        m.put("Re", "ℜ");
        m.put("ReverseElement", "∋");
        m.put("ReverseEquilibrium", "⇋");
        m.put("ReverseUpEquilibrium", "⥯");
        m.put("Rfr", "ℜ");
        m.put("Rho", "Ρ");
        m.put("RightAngleBracket", "⟩");
        m.put("RightArrow", "→");
        m.put("RightArrowBar", "⇥");
        m.put("RightArrowLeftArrow", "⇄");
        m.put("RightCeiling", "⌉");
        m.put("RightDoubleBracket", "⟧");
        m.put("RightDownTeeVector", "⥝");
        m.put("RightDownVector", "⇂");
        m.put("RightDownVectorBar", "⥕");
        m.put("RightFloor", "⌋");
        m.put("RightTee", "⊢");
        m.put("RightTeeArrow", "↦");
        m.put("RightTeeVector", "⥛");
        m.put("RightTriangle", "⊳");
        m.put("RightTriangleBar", "⧐");
        m.put("RightTriangleEqual", "⊵");
        m.put("RightUpDownVector", "⥏");
        m.put("RightUpTeeVector", "⥜");
        m.put("RightUpVector", "↾");
        m.put("RightUpVectorBar", "⥔");
        m.put("RightVector", "⇀");
        m.put("RightVectorBar", "⥓");
        m.put("Rightarrow", "⇒");
        m.put("Ropf", "ℝ");
        m.put("RoundImplies", "⥰");
        m.put("Rrightarrow", "⇛");
        m.put("Rscr", "ℛ");
        m.put("Rsh", "↱");
        m.put("RuleDelayed", "⧴");
        m.put("SHCHcy", "Щ");
        m.put("SHcy", "Ш");
        m.put("SOFTcy", "Ь");
        m.put("Sacute", "Ś");
        m.put("Sc", "⪼");
        m.put("Scaron", "Š");
        m.put("Scedil", "Ş");
        m.put("Scirc", "Ŝ");
        m.put("Scy", "С");
        m.put("Sfr", "𝔖");
        m.put("ShortDownArrow", "↓");
        m.put("ShortLeftArrow", "←");
        m.put("ShortRightArrow", "→");
        m.put("ShortUpArrow", "↑");
        m.put("Sigma", "Σ");
        m.put("SmallCircle", "∘");
        m.put("Sopf", "𝕊");
        m.put("Sqrt", "√");
        m.put("Square", "□");
        m.put("SquareIntersection", "⊓");
        m.put("SquareSubset", "⊏");
        m.put("SquareSubsetEqual", "⊑");
        m.put("SquareSuperset", "⊐");
        m.put("SquareSupersetEqual", "⊒");
        m.put("SquareUnion", "⊔");
        m.put("Sscr", "𝒮");
        m.put("Star", "⋆");
        m.put("Sub", "⋐");
        m.put("Subset", "⋐");
        m.put("SubsetEqual", "⊆");
        m.put("Succeeds", "≻");
        m.put("SucceedsEqual", "⪰");
        m.put("SucceedsSlantEqual", "≽");
        m.put("SucceedsTilde", "≿");
        m.put("SuchThat", "∋");
        m.put("Sum", "∑");
        m.put("Sup", "⋑");
        m.put("Superset", "⊃");
        m.put("SupersetEqual", "⊇");
        m.put("Supset", "⋑");
        m.put("THORN", "Þ");
        m.put("TRADE", "™");
        m.put("TSHcy", "Ћ");
        m.put("TScy", "Ц");
        m.put("Tab", "\t");
        m.put("Tau", "Τ");
        m.put("Tcaron", "Ť");
        m.put("Tcedil", "Ţ");
        m.put("Tcy", "Т");
        m.put("Tfr", "𝔗");
        m.put("Therefore", "∴");
        m.put("Theta", "Θ");
        m.put("ThickSpace", "  ");
        m.put("ThinSpace", " ");
        m.put("Tilde", "∼");
        m.put("TildeEqual", "≃");
        m.put("TildeFullEqual", "≅");
        m.put("TildeTilde", "≈");
        m.put("Topf", "𝕋");
        m.put("TripleDot", "⃛");
        m.put("Tscr", "𝒯");
        m.put("Tstrok", "Ŧ");
        m.put("Uacute", "Ú");
        m.put("Uarr", "↟");
        m.put("Uarrocir", "⥉");
        m.put("Ubrcy", "Ў");
        m.put("Ubreve", "Ŭ");
        m.put("Ucirc", "Û");
        m.put("Ucy", "У");
        m.put("Udblac", "Ű");
        m.put("Ufr", "𝔘");
        m.put("Ugrave", "Ù");
        m.put("Umacr", "Ū");
        m.put("UnderBar", "_");
        m.put("UnderBrace", "⏟");
        m.put("UnderBracket", "⎵");
        m.put("UnderParenthesis", "⏝");
        m.put("Union", "⋃");
        m.put("UnionPlus", "⊎");
        m.put("Uogon", "Ų");
        m.put("Uopf", "𝕌");
        m.put("UpArrow", "↑");
        m.put("UpArrowBar", "⤒");
        m.put("UpArrowDownArrow", "⇅");
        m.put("UpDownArrow", "↕");
        m.put("UpEquilibrium", "⥮");
        m.put("UpTee", "⊥");
        m.put("UpTeeArrow", "↥");
        m.put("Uparrow", "⇑");
        m.put("Updownarrow", "⇕");
        m.put("UpperLeftArrow", "↖");
        m.put("UpperRightArrow", "↗");
        m.put("Upsi", "ϒ");
        m.put("Upsilon", "Υ");
        m.put("Uring", "Ů");
        m.put("Uscr", "𝒰");
        m.put("Utilde", "Ũ");
        m.put("Uuml", "Ü");
        m.put("VDash", "⊫");
        m.put("Vbar", "⫫");
        m.put("Vcy", "В");
        m.put("Vdash", "⊩");
        m.put("Vdashl", "⫦");
        m.put("Vee", "⋁");
        m.put("Verbar", "‖");
        m.put("Vert", "‖");
        m.put("VerticalBar", "∣");
        m.put("VerticalLine", "|");
        m.put("VerticalSeparator", "❘");
        m.put("VerticalTilde", "≀");
        m.put("VeryThinSpace", " ");
        m.put("Vfr", "𝔙");
        m.put("Vopf", "𝕍");
        m.put("Vscr", "𝒱");
        m.put("Vvdash", "⊪");
        m.put("Wcirc", "Ŵ");
        m.put("Wedge", "⋀");
        m.put("Wfr", "𝔚");
        m.put("Wopf", "𝕎");
        m.put("Wscr", "𝒲");
        m.put("Xfr", "𝔛");
        m.put("Xi", "Ξ");
        m.put("Xopf", "𝕏");
        m.put("Xscr", "𝒳");
        m.put("YAcy", "Я");
        m.put("YIcy", "Ї");
        m.put("YUcy", "Ю");
        m.put("Yacute", "Ý");
        m.put("Ycirc", "Ŷ");
        m.put("Ycy", "Ы");
        m.put("Yfr", "𝔜");
        m.put("Yopf", "𝕐");
        m.put("Yscr", "𝒴");
        m.put("Yuml", "Ÿ");
        m.put("ZHcy", "Ж");
        m.put("Zacute", "Ź");
        m.put("Zcaron", "Ž");
        m.put("Zcy", "З");
        m.put("Zdot", "Ż");
        m.put("ZeroWidthSpace", "​");
        m.put("Zeta", "Ζ");
        m.put("Zfr", "ℨ");
        m.put("Zopf", "ℤ");
        m.put("Zscr", "𝒵");
        m.put("aacute", "á");
        m.put("abreve", "ă");
        m.put("ac", "∾");
        m.put("acE", "∾̳");
        m.put("acd", "∿");
        m.put("acirc", "â");
        m.put("acute", "´");
        m.put("acy", "а");
        m.put("aelig", "æ");
        m.put("af", "⁡");
        m.put("afr", "𝔞");
        m.put("agrave", "à");
        m.put("alefsym", "ℵ");
        m.put("aleph", "ℵ");
        m.put("alpha", "α");
        m.put("amacr", "ā");
        m.put("amalg", "⨿");
        m.put("amp", "&");
        m.put("and", "∧");
        m.put("andand", "⩕");
        m.put("andd", "⩜");
        m.put("andslope", "⩘");
        m.put("andv", "⩚");
        m.put("ang", "∠");
        m.put("ange", "⦤");
        m.put("angle", "∠");
        m.put("angmsd", "∡");
        m.put("angmsdaa", "⦨");
        m.put("angmsdab", "⦩");
        m.put("angmsdac", "⦪");
        m.put("angmsdad", "⦫");
        m.put("angmsdae", "⦬");
        m.put("angmsdaf", "⦭");
        m.put("angmsdag", "⦮");
        m.put("angmsdah", "⦯");
        m.put("angrt", "∟");
        m.put("angrtvb", "⊾");
        m.put("angrtvbd", "⦝");
        m.put("angsph", "∢");
        m.put("angst", "Å");
        m.put("angzarr", "⍼");
        m.put("aogon", "ą");
        m.put("aopf", "𝕒");
        m.put("ap", "≈");
        m.put("apE", "⩰");
        m.put("apacir", "⩯");
        m.put("ape", "≊");
        m.put("apid", "≋");
        m.put("apos", "'");
        m.put("approx", "≈");
        m.put("approxeq", "≊");
        m.put("aring", "å");
        m.put("ascr", "𝒶");
        m.put("ast", "*");
        m.put("asymp", "≈");
        m.put("asympeq", "≍");
        m.put("atilde", "ã");
        m.put("auml", "ä");
        m.put("awconint", "∳");
        m.put("awint", "⨑");
        m.put("bNot", "⫭");
        m.put("backcong", "≌");
        m.put("backepsilon", "϶");
        m.put("backprime", "‵");
        m.put("backsim", "∽");
        m.put("backsimeq", "⋍");
        m.put("barvee", "⊽");
        m.put("barwed", "⌅");
        m.put("barwedge", "⌅");
        m.put("bbrk", "⎵");
        m.put("bbrktbrk", "⎶");
        m.put("bcong", "≌");
        m.put("bcy", "б");
        m.put("bdquo", "„");
        m.put("becaus", "∵");
        m.put("because", "∵");
        m.put("bemptyv", "⦰");
        m.put("bepsi", "϶");
        m.put("bernou", "ℬ");
        m.put("beta", "β");
        m.put("beth", "ℶ");
        m.put("between", "≬");
        m.put("bfr", "𝔟");
        m.put("bigcap", "⋂");
        m.put("bigcirc", "◯");
        m.put("bigcup", "⋃");
        m.put("bigodot", "⨀");
        m.put("bigoplus", "⨁");
        m.put("bigotimes", "⨂");
        m.put("bigsqcup", "⨆");
        m.put("bigstar", "★");
        m.put("bigtriangledown", "▽");
        m.put("bigtriangleup", "△");
        m.put("biguplus", "⨄");
        m.put("bigvee", "⋁");
        m.put("bigwedge", "⋀");
        m.put("bkarow", "⤍");
        m.put("blacklozenge", "⧫");
        m.put("blacksquare", "▪");
        m.put("blacktriangle", "▴");
        m.put("blacktriangledown", "▾");
        m.put("blacktriangleleft", "◂");
        m.put("blacktriangleright", "▸");
        m.put("blank", "␣");
        m.put("blk12", "▒");
        m.put("blk14", "░");
        m.put("blk34", "▓");
        m.put("block", "█");
        m.put("bne", "=⃥");
        m.put("bnequiv", "≡⃥");
        m.put("bnot", "⌐");
        m.put("bopf", "𝕓");
        m.put("bot", "⊥");
        m.put("bottom", "⊥");
        m.put("bowtie", "⋈");
        m.put("boxDL", "╗");
        m.put("boxDR", "╔");
        m.put("boxDl", "╖");
        m.put("boxDr", "╓");
        m.put("boxH", "═");
        m.put("boxHD", "╦");
        m.put("boxHU", "╩");
        m.put("boxHd", "╤");
        m.put("boxHu", "╧");
        m.put("boxUL", "╝");
        m.put("boxUR", "╚");
        m.put("boxUl", "╜");
        m.put("boxUr", "╙");
        m.put("boxV", "║");
        m.put("boxVH", "╬");
        m.put("boxVL", "╣");
        m.put("boxVR", "╠");
        m.put("boxVh", "╫");
        m.put("boxVl", "╢");
        m.put("boxVr", "╟");
        m.put("boxbox", "⧉");
        m.put("boxdL", "╕");
        m.put("boxdR", "╒");
        m.put("boxdl", "┐");
        m.put("boxdr", "┌");
        m.put("boxh", "─");
        m.put("boxhD", "╥");
        m.put("boxhU", "╨");
        m.put("boxhd", "┬");
        m.put("boxhu", "┴");
        m.put("boxminus", "⊟");
        m.put("boxplus", "⊞");
        m.put("boxtimes", "⊠");
        m.put("boxuL", "╛");
        m.put("boxuR", "╘");
        m.put("boxul", "┘");
        m.put("boxur", "└");
        m.put("boxv", "│");
        m.put("boxvH", "╪");
        m.put("boxvL", "╡");
        m.put("boxvR", "╞");
        m.put("boxvh", "┼");
        m.put("boxvl", "┤");
        m.put("boxvr", "├");
        m.put("bprime", "‵");
        m.put("breve", "˘");
        m.put("brvbar", "¦");
        m.put("bscr", "𝒷");
        m.put("bsemi", "⁏");
        m.put("bsim", "∽");
        m.put("bsime", "⋍");
        m.put("bsol", "\\");
        m.put("bsolb", "⧅");
        m.put("bsolhsub", "⟈");
        m.put("bull", "•");
        m.put("bullet", "•");
        m.put("bump", "≎");
        m.put("bumpE", "⪮");
        m.put("bumpe", "≏");
        m.put("bumpeq", "≏");
        m.put("cacute", "ć");
        m.put("cap", "∩");
        m.put("capand", "⩄");
        m.put("capbrcup", "⩉");
        m.put("capcap", "⩋");
        m.put("capcup", "⩇");
        m.put("capdot", "⩀");
        m.put("caps", "∩︀");
        m.put("caret", "⁁");
        m.put("caron", "ˇ");
        m.put("ccaps", "⩍");
        m.put("ccaron", "č");
        m.put("ccedil", "ç");
        m.put("ccirc", "ĉ");
        m.put("ccups", "⩌");
        m.put("ccupssm", "⩐");
        m.put("cdot", "ċ");
        m.put("cedil", "¸");
        m.put("cemptyv", "⦲");
        m.put("cent", "¢");
        m.put("centerdot", "·");
        m.put("cfr", "𝔠");
        m.put("chcy", "ч");
        m.put("check", "✓");
        m.put("checkmark", "✓");
        m.put("chi", "χ");
        m.put("cir", "○");
        m.put("cirE", "⧃");
        m.put("circ", "ˆ");
        m.put("circeq", "≗");
        m.put("circlearrowleft", "↺");
        m.put("circlearrowright", "↻");
        m.put("circledR", "®");
        m.put("circledS", "Ⓢ");
        m.put("circledast", "⊛");
        m.put("circledcirc", "⊚");
        m.put("circleddash", "⊝");
        m.put("cire", "≗");
        m.put("cirfnint", "⨐");
        m.put("cirmid", "⫯");
        m.put("cirscir", "⧂");
        m.put("clubs", "♣");
        m.put("clubsuit", "♣");
        m.put("colon", ":");
        m.put("colone", "≔");
        m.put("coloneq", "≔");
        m.put("comma", ",");
        m.put("commat", "@");
        m.put("comp", "∁");
        m.put("compfn", "∘");
        m.put("complement", "∁");
        m.put("complexes", "ℂ");
        m.put("cong", "≅");
        m.put("congdot", "⩭");
        m.put("conint", "∮");
        m.put("copf", "𝕔");
        m.put("coprod", "∐");
        m.put("copy", "©");
        m.put("copysr", "℗");
        m.put("crarr", "↵");
        m.put("cross", "✗");
        m.put("cscr", "𝒸");
        m.put("csub", "⫏");
        m.put("csube", "⫑");
        m.put("csup", "⫐");
        m.put("csupe", "⫒");
        m.put("ctdot", "⋯");
        m.put("cudarrl", "⤸");
        m.put("cudarrr", "⤵");
        m.put("cuepr", "⋞");
        m.put("cuesc", "⋟");
        m.put("cularr", "↶");
        m.put("cularrp", "⤽");
        m.put("cup", "∪");
        m.put("cupbrcap", "⩈");
        m.put("cupcap", "⩆");
        m.put("cupcup", "⩊");
        m.put("cupdot", "⊍");
        m.put("cupor", "⩅");
        m.put("cups", "∪︀");
        m.put("curarr", "↷");
        m.put("curarrm", "⤼");
        m.put("curlyeqprec", "⋞");
        m.put("curlyeqsucc", "⋟");
        m.put("curlyvee", "⋎");
        m.put("curlywedge", "⋏");
        m.put("curren", "¤");
        m.put("curvearrowleft", "↶");
        m.put("curvearrowright", "↷");
        m.put("cuvee", "⋎");
        m.put("cuwed", "⋏");
        m.put("cwconint", "∲");
        m.put("cwint", "∱");
        m.put("cylcty", "⌭");
        m.put("dArr", "⇓");
        m.put("dHar", "⥥");
        m.put("dagger", "†");
        m.put("daleth", "ℸ");
        m.put("darr", "↓");
        m.put("dash", "‐");
        m.put("dashv", "⊣");
        m.put("dbkarow", "⤏");
        m.put("dblac", "˝");
        m.put("dcaron", "ď");
        m.put("dcy", "д");
        m.put("dd", "ⅆ");
        m.put("ddagger", "‡");
        m.put("ddarr", "⇊");
        m.put("ddotseq", "⩷");
        m.put("deg", "°");
        m.put("delta", "δ");
        m.put("demptyv", "⦱");
        m.put("dfisht", "⥿");
        m.put("dfr", "𝔡");
        m.put("dharl", "⇃");
        m.put("dharr", "⇂");
        m.put("diam", "⋄");
        m.put("diamond", "⋄");
        m.put("diamondsuit", "♦");
        m.put("diams", "♦");
        m.put("die", "¨");
        m.put("digamma", "ϝ");
        m.put("disin", "⋲");
        m.put("div", "÷");
        m.put("divide", "÷");
        m.put("divideontimes", "⋇");
        m.put("divonx", "⋇");
        m.put("djcy", "ђ");
        m.put("dlcorn", "⌞");
        m.put("dlcrop", "⌍");
        m.put("dollar", "$");
        m.put("dopf", "𝕕");
        m.put("dot", "˙");
        m.put("doteq", "≐");
        m.put("doteqdot", "≑");
        m.put("dotminus", "∸");
        m.put("dotplus", "∔");
        m.put("dotsquare", "⊡");
        m.put("doublebarwedge", "⌆");
        m.put("downarrow", "↓");
        m.put("downdownarrows", "⇊");
        m.put("downharpoonleft", "⇃");
        m.put("downharpoonright", "⇂");
        m.put("drbkarow", "⤐");
        m.put("drcorn", "⌟");
        m.put("drcrop", "⌌");
        m.put("dscr", "𝒹");
        m.put("dscy", "ѕ");
        m.put("dsol", "⧶");
        m.put("dstrok", "đ");
        m.put("dtdot", "⋱");
        m.put("dtri", "▿");
        m.put("dtrif", "▾");
        m.put("duarr", "⇵");
        m.put("duhar", "⥯");
        m.put("dwangle", "⦦");
        m.put("dzcy", "џ");
        m.put("dzigrarr", "⟿");
        m.put("eDDot", "⩷");
        m.put("eDot", "≑");
        m.put("eacute", "é");
        m.put("easter", "⩮");
        m.put("ecaron", "ě");
        m.put("ecir", "≖");
        m.put("ecirc", "ê");
        m.put("ecolon", "≕");
        m.put("ecy", "э");
        m.put("edot", "ė");
        m.put("ee", "ⅇ");
        m.put("efDot", "≒");
        m.put("efr", "𝔢");
        m.put("eg", "⪚");
        m.put("egrave", "è");
        m.put("egs", "⪖");
        m.put("egsdot", "⪘");
        m.put("el", "⪙");
        m.put("elinters", "⏧");
        m.put("ell", "ℓ");
        m.put("els", "⪕");
        m.put("elsdot", "⪗");
        m.put("emacr", "ē");
        m.put("empty", "∅");
        m.put("emptyset", "∅");
        m.put("emptyv", "∅");
        m.put("emsp13", " ");
        m.put("emsp14", " ");
        m.put("emsp", " ");
        m.put("eng", "ŋ");
        m.put("ensp", " ");
        m.put("eogon", "ę");
        m.put("eopf", "𝕖");
        m.put("epar", "⋕");
        m.put("eparsl", "⧣");
        m.put("eplus", "⩱");
        m.put("epsi", "ε");
        m.put("epsilon", "ε");
        m.put("epsiv", "ϵ");
        m.put("eqcirc", "≖");
        m.put("eqcolon", "≕");
        m.put("eqsim", "≂");
        m.put("eqslantgtr", "⪖");
        m.put("eqslantless", "⪕");
        m.put("equals", "=");
        m.put("equest", "≟");
        m.put("equiv", "≡");
        m.put("equivDD", "⩸");
        m.put("eqvparsl", "⧥");
        m.put("erDot", "≓");
        m.put("erarr", "⥱");
        m.put("escr", "ℯ");
        m.put("esdot", "≐");
        m.put("esim", "≂");
        m.put("eta", "η");
        m.put("eth", "ð");
        m.put("euml", "ë");
        m.put("euro", "€");
        m.put("excl", "!");
        m.put("exist", "∃");
        m.put("expectation", "ℰ");
        m.put("exponentiale", "ⅇ");
        m.put("fallingdotseq", "≒");
        m.put("fcy", "ф");
        m.put("female", "♀");
        m.put("ffilig", "ffi");
        m.put("fflig", "ff");
        m.put("ffllig", "ffl");
        m.put("ffr", "𝔣");
        m.put("filig", "fi");
        m.put("fjlig", "fj");
        m.put("flat", "♭");
        m.put("fllig", "fl");
        m.put("fltns", "▱");
        m.put("fnof", "ƒ");
        m.put("fopf", "𝕗");
        m.put("forall", "∀");
        m.put("fork", "⋔");
        m.put("forkv", "⫙");
        m.put("fpartint", "⨍");
        m.put("frac12", "½");
        m.put("frac13", "⅓");
        m.put("frac14", "¼");
        m.put("frac15", "⅕");
        m.put("frac16", "⅙");
        m.put("frac18", "⅛");
        m.put("frac23", "⅔");
        m.put("frac25", "⅖");
        m.put("frac34", "¾");
        m.put("frac35", "⅗");
        m.put("frac38", "⅜");
        m.put("frac45", "⅘");
        m.put("frac56", "⅚");
        m.put("frac58", "⅝");
        m.put("frac78", "⅞");
        m.put("frasl", "⁄");
        m.put("frown", "⌢");
        m.put("fscr", "𝒻");
        m.put("gE", "≧");
        m.put("gEl", "⪌");
        m.put("gacute", "ǵ");
        m.put("gamma", "γ");
        m.put("gammad", "ϝ");
        m.put("gap", "⪆");
        m.put("gbreve", "ğ");
        m.put("gcirc", "ĝ");
        m.put("gcy", "г");
        m.put("gdot", "ġ");
        m.put("ge", "≥");
        m.put("gel", "⋛");
        m.put("geq", "≥");
        m.put("geqq", "≧");
        m.put("geqslant", "⩾");
        m.put("ges", "⩾");
        m.put("gescc", "⪩");
        m.put("gesdot", "⪀");
        m.put("gesdoto", "⪂");
        m.put("gesdotol", "⪄");
        m.put("gesl", "⋛︀");
        m.put("gesles", "⪔");
        m.put("gfr", "𝔤");
        m.put("gg", "≫");
        m.put("ggg", "⋙");
        m.put("gimel", "ℷ");
        m.put("gjcy", "ѓ");
        m.put("gl", "≷");
        m.put("glE", "⪒");
        m.put("gla", "⪥");
        m.put("glj", "⪤");
        m.put("gnE", "≩");
        m.put("gnap", "⪊");
        m.put("gnapprox", "⪊");
        m.put("gne", "⪈");
        m.put("gneq", "⪈");
        m.put("gneqq", "≩");
        m.put("gnsim", "⋧");
        m.put("gopf", "𝕘");
        m.put("grave", "`");
        m.put("gscr", "ℊ");
        m.put("gsim", "≳");
        m.put("gsime", "⪎");
        m.put("gsiml", "⪐");
        m.put("gt", ">");
        m.put("gtcc", "⪧");
        m.put("gtcir", "⩺");
        m.put("gtdot", "⋗");
        m.put("gtlPar", "⦕");
        m.put("gtquest", "⩼");
        m.put("gtrapprox", "⪆");
        m.put("gtrarr", "⥸");
        m.put("gtrdot", "⋗");
        m.put("gtreqless", "⋛");
        m.put("gtreqqless", "⪌");
        m.put("gtrless", "≷");
        m.put("gtrsim", "≳");
        m.put("gvertneqq", "≩︀");
        m.put("gvnE", "≩︀");
        m.put("hArr", "⇔");
        m.put("hairsp", " ");
        m.put("half", "½");
        m.put("hamilt", "ℋ");
        m.put("hardcy", "ъ");
        m.put("harr", "↔");
        m.put("harrcir", "⥈");
        m.put("harrw", "↭");
        m.put("hbar", "ℏ");
        m.put("hcirc", "ĥ");
        m.put("hearts", "♥");
        m.put("heartsuit", "♥");
        m.put("hellip", "…");
        m.put("hercon", "⊹");
        m.put("hfr", "𝔥");
        m.put("hksearow", "⤥");
        m.put("hkswarow", "⤦");
        m.put("hoarr", "⇿");
        m.put("homtht", "∻");
        m.put("hookleftarrow", "↩");
        m.put("hookrightarrow", "↪");
        m.put("hopf", "𝕙");
        m.put("horbar", "―");
        m.put("hscr", "𝒽");
        m.put("hslash", "ℏ");
        m.put("hstrok", "ħ");
        m.put("hybull", "⁃");
        m.put("hyphen", "‐");
        m.put("iacute", "í");
        m.put("ic", "⁣");
        m.put("icirc", "î");
        m.put("icy", "и");
        m.put("iecy", "е");
        m.put("iexcl", "¡");
        m.put("iff", "⇔");
        m.put("ifr", "𝔦");
        m.put("igrave", "ì");
        m.put("ii", "ⅈ");
        m.put("iiiint", "⨌");
        m.put("iiint", "∭");
        m.put("iinfin", "⧜");
        m.put("iiota", "℩");
        m.put("ijlig", "ij");
        m.put("imacr", "ī");
        m.put("image", "ℑ");
        m.put("imagline", "ℐ");
        m.put("imagpart", "ℑ");
        m.put("imath", "ı");
        m.put("imof", "⊷");
        m.put("imped", "Ƶ");
        m.put("in", "∈");
        m.put("incare", "℅");
        m.put("infin", "∞");
        m.put("infintie", "⧝");
        m.put("inodot", "ı");
        m.put("int", "∫");
        m.put("intcal", "⊺");
        m.put("integers", "ℤ");
        m.put("intercal", "⊺");
        m.put("intlarhk", "⨗");
        m.put("intprod", "⨼");
        m.put("iocy", "ё");
        m.put("iogon", "į");
        m.put("iopf", "𝕚");
        m.put("iota", "ι");
        m.put("iprod", "⨼");
        m.put("iquest", "¿");
        m.put("iscr", "𝒾");
        m.put("isin", "∈");
        m.put("isinE", "⋹");
        m.put("isindot", "⋵");
        m.put("isins", "⋴");
        m.put("isinsv", "⋳");
        m.put("isinv", "∈");
        m.put("it", "⁢");
        m.put("itilde", "ĩ");
        m.put("iukcy", "і");
        m.put("iuml", "ï");
        m.put("jcirc", "ĵ");
        m.put("jcy", "й");
        m.put("jfr", "𝔧");
        m.put("jmath", "ȷ");
        m.put("jopf", "𝕛");
        m.put("jscr", "𝒿");
        m.put("jsercy", "ј");
        m.put("jukcy", "є");
        m.put("kappa", "κ");
        m.put("kappav", "ϰ");
        m.put("kcedil", "ķ");
        m.put("kcy", "к");
        m.put("kfr", "𝔨");
        m.put("kgreen", "ĸ");
        m.put("khcy", "х");
        m.put("kjcy", "ќ");
        m.put("kopf", "𝕜");
        m.put("kscr", "𝓀");
        m.put("lAarr", "⇚");
        m.put("lArr", "⇐");
        m.put("lAtail", "⤛");
        m.put("lBarr", "⤎");
        m.put("lE", "≦");
        m.put("lEg", "⪋");
        m.put("lHar", "⥢");
        m.put("lacute", "ĺ");
        m.put("laemptyv", "⦴");
        m.put("lagran", "ℒ");
        m.put("lambda", "λ");
        m.put("lang", "⟨");
        m.put("langd", "⦑");
        m.put("langle", "⟨");
        m.put("lap", "⪅");
        m.put("laquo", "«");
        m.put("larr", "←");
        m.put("larrb", "⇤");
        m.put("larrbfs", "⤟");
        m.put("larrfs", "⤝");
        m.put("larrhk", "↩");
        m.put("larrlp", "↫");
        m.put("larrpl", "⤹");
        m.put("larrsim", "⥳");
        m.put("larrtl", "↢");
        m.put("lat", "⪫");
        m.put("latail", "⤙");
        m.put("late", "⪭");
        m.put("lates", "⪭︀");
        m.put("lbarr", "⤌");
        m.put("lbbrk", "❲");
        m.put("lbrace", "{");
        m.put("lbrack", "[");
        m.put("lbrke", "⦋");
        m.put("lbrksld", "⦏");
        m.put("lbrkslu", "⦍");
        m.put("lcaron", "ľ");
        m.put("lcedil", "ļ");
        m.put("lceil", "⌈");
        m.put("lcub", "{");
        m.put("lcy", "л");
        m.put("ldca", "⤶");
        m.put("ldquo", "“");
        m.put("ldquor", "„");
        m.put("ldrdhar", "⥧");
        m.put("ldrushar", "⥋");
        m.put("ldsh", "↲");
        m.put("le", "≤");
        m.put("leftarrow", "←");
        m.put("leftarrowtail", "↢");
        m.put("leftharpoondown", "↽");
        m.put("leftharpoonup", "↼");
        m.put("leftleftarrows", "⇇");
        m.put("leftrightarrow", "↔");
        m.put("leftrightarrows", "⇆");
        m.put("leftrightharpoons", "⇋");
        m.put("leftrightsquigarrow", "↭");
        m.put("leftthreetimes", "⋋");
        m.put("leg", "⋚");
        m.put("leq", "≤");
        m.put("leqq", "≦");
        m.put("leqslant", "⩽");
        m.put("les", "⩽");
        m.put("lescc", "⪨");
        m.put("lesdot", "⩿");
        m.put("lesdoto", "⪁");
        m.put("lesdotor", "⪃");
        m.put("lesg", "⋚︀");
        m.put("lesges", "⪓");
        m.put("lessapprox", "⪅");
        m.put("lessdot", "⋖");
        m.put("lesseqgtr", "⋚");
        m.put("lesseqqgtr", "⪋");
        m.put("lessgtr", "≶");
        m.put("lesssim", "≲");
        m.put("lfisht", "⥼");
        m.put("lfloor", "⌊");
        m.put("lfr", "𝔩");
        m.put("lg", "≶");
        m.put("lgE", "⪑");
        m.put("lhard", "↽");
        m.put("lharu", "↼");
        m.put("lharul", "⥪");
        m.put("lhblk", "▄");
        m.put("ljcy", "љ");
        m.put("ll", "≪");
        m.put("llarr", "⇇");
        m.put("llcorner", "⌞");
        m.put("llhard", "⥫");
        m.put("lltri", "◺");
        m.put("lmidot", "ŀ");
        m.put("lmoust", "⎰");
        m.put("lmoustache", "⎰");
        m.put("lnE", "≨");
        m.put("lnap", "⪉");
        m.put("lnapprox", "⪉");
        m.put("lne", "⪇");
        m.put("lneq", "⪇");
        m.put("lneqq", "≨");
        m.put("lnsim", "⋦");
        m.put("loang", "⟬");
        m.put("loarr", "⇽");
        m.put("lobrk", "⟦");
        m.put("longleftarrow", "⟵");
        m.put("longleftrightarrow", "⟷");
        m.put("longmapsto", "⟼");
        m.put("longrightarrow", "⟶");
        m.put("looparrowleft", "↫");
        m.put("looparrowright", "↬");
        m.put("lopar", "⦅");
        m.put("lopf", "𝕝");
        m.put("loplus", "⨭");
        m.put("lotimes", "⨴");
        m.put("lowast", "∗");
        m.put("lowbar", "_");
        m.put("loz", "◊");
        m.put("lozenge", "◊");
        m.put("lozf", "⧫");
        m.put("lpar", "(");
        m.put("lparlt", "⦓");
        m.put("lrarr", "⇆");
        m.put("lrcorner", "⌟");
        m.put("lrhar", "⇋");
        m.put("lrhard", "⥭");
        m.put("lrm", "‎");
        m.put("lrtri", "⊿");
        m.put("lsaquo", "‹");
        m.put("lscr", "𝓁");
        m.put("lsh", "↰");
        m.put("lsim", "≲");
        m.put("lsime", "⪍");
        m.put("lsimg", "⪏");
        m.put("lsqb", "[");
        m.put("lsquo", "‘");
        m.put("lsquor", "‚");
        m.put("lstrok", "ł");
        m.put("lt", "<");
        m.put("ltcc", "⪦");
        m.put("ltcir", "⩹");
        m.put("ltdot", "⋖");
        m.put("lthree", "⋋");
        m.put("ltimes", "⋉");
        m.put("ltlarr", "⥶");
        m.put("ltquest", "⩻");
        m.put("ltrPar", "⦖");
        m.put("ltri", "◃");
        m.put("ltrie", "⊴");
        m.put("ltrif", "◂");
        m.put("lurdshar", "⥊");
        m.put("luruhar", "⥦");
        m.put("lvertneqq", "≨︀");
        m.put("lvnE", "≨︀");
        m.put("mDDot", "∺");
        m.put("macr", "¯");
        m.put("male", "♂");
        m.put("malt", "✠");
        m.put("maltese", "✠");
        m.put("map", "↦");
        m.put("mapsto", "↦");
        m.put("mapstodown", "↧");
        m.put("mapstoleft", "↤");
        m.put("mapstoup", "↥");
        m.put("marker", "▮");
        m.put("mcomma", "⨩");
        m.put("mcy", "м");
        m.put("mdash", "—");
        m.put("measuredangle", "∡");
        m.put("mfr", "𝔪");
        m.put("mho", "℧");
        m.put("micro", "µ");
        m.put("mid", "∣");
        m.put("midast", "*");
        m.put("midcir", "⫰");
        m.put("middot", "·");
        m.put("minus", "−");
        m.put("minusb", "⊟");
        m.put("minusd", "∸");
        m.put("minusdu", "⨪");
        m.put("mlcp", "⫛");
        m.put("mldr", "…");
        m.put("mnplus", "∓");
        m.put("models", "⊧");
        m.put("mopf", "𝕞");
        m.put("mp", "∓");
        m.put("mscr", "𝓂");
        m.put("mstpos", "∾");
        m.put("mu", "μ");
        m.put("multimap", "⊸");
        m.put("mumap", "⊸");
        m.put("nGg", "⋙̸");
        m.put("nGt", "≫⃒");
        m.put("nGtv", "≫̸");
        m.put("nLeftarrow", "⇍");
        m.put("nLeftrightarrow", "⇎");
        m.put("nLl", "⋘̸");
        m.put("nLt", "≪⃒");
        m.put("nLtv", "≪̸");
        m.put("nRightarrow", "⇏");
        m.put("nVDash", "⊯");
        m.put("nVdash", "⊮");
        m.put("nabla", "∇");
        m.put("nacute", "ń");
        m.put("nang", "∠⃒");
        m.put("nap", "≉");
        m.put("napE", "⩰̸");
        m.put("napid", "≋̸");
        m.put("napos", "ʼn");
        m.put("napprox", "≉");
        m.put("natur", "♮");
        m.put("natural", "♮");
        m.put("naturals", "ℕ");
        m.put("nbsp", " ");
        m.put("nbump", "≎̸");
        m.put("nbumpe", "≏̸");
        m.put("ncap", "⩃");
        m.put("ncaron", "ň");
        m.put("ncedil", "ņ");
        m.put("ncong", "≇");
        m.put("ncongdot", "⩭̸");
        m.put("ncup", "⩂");
        m.put("ncy", "н");
        m.put("ndash", "–");
        m.put("ne", "≠");
        m.put("neArr", "⇗");
        m.put("nearhk", "⤤");
        m.put("nearr", "↗");
        m.put("nearrow", "↗");
        m.put("nedot", "≐̸");
        m.put("nequiv", "≢");
        m.put("nesear", "⤨");
        m.put("nesim", "≂̸");
        m.put("nexist", "∄");
        m.put("nexists", "∄");
        m.put("nfr", "𝔫");
        m.put("ngE", "≧̸");
        m.put("nge", "≱");
        m.put("ngeq", "≱");
        m.put("ngeqq", "≧̸");
        m.put("ngeqslant", "⩾̸");
        m.put("nges", "⩾̸");
        m.put("ngsim", "≵");
        m.put("ngt", "≯");
        m.put("ngtr", "≯");
        m.put("nhArr", "⇎");
        m.put("nharr", "↮");
        m.put("nhpar", "⫲");
        m.put("ni", "∋");
        m.put("nis", "⋼");
        m.put("nisd", "⋺");
        m.put("niv", "∋");
        m.put("njcy", "њ");
        m.put("nlArr", "⇍");
        m.put("nlE", "≦̸");
        m.put("nlarr", "↚");
        m.put("nldr", "‥");
        m.put("nle", "≰");
        m.put("nleftarrow", "↚");
        m.put("nleftrightarrow", "↮");
        m.put("nleq", "≰");
        m.put("nleqq", "≦̸");
        m.put("nleqslant", "⩽̸");
        m.put("nles", "⩽̸");
        m.put("nless", "≮");
        m.put("nlsim", "≴");
        m.put("nlt", "≮");
        m.put("nltri", "⋪");
        m.put("nltrie", "⋬");
        m.put("nmid", "∤");
        m.put("nopf", "𝕟");
        m.put("not", "¬");
        m.put("notin", "∉");
        m.put("notinE", "⋹̸");
        m.put("notindot", "⋵̸");
        m.put("notinva", "∉");
        m.put("notinvb", "⋷");
        m.put("notinvc", "⋶");
        m.put("notni", "∌");
        m.put("notniva", "∌");
        m.put("notnivb", "⋾");
        m.put("notnivc", "⋽");
        m.put("npar", "∦");
        m.put("nparallel", "∦");
        m.put("nparsl", "⫽⃥");
        m.put("npart", "∂̸");
        m.put("npolint", "⨔");
        m.put("npr", "⊀");
        m.put("nprcue", "⋠");
        m.put("npre", "⪯̸");
        m.put("nprec", "⊀");
        m.put("npreceq", "⪯̸");
        m.put("nrArr", "⇏");
        m.put("nrarr", "↛");
        m.put("nrarrc", "⤳̸");
        m.put("nrarrw", "↝̸");
        m.put("nrightarrow", "↛");
        m.put("nrtri", "⋫");
        m.put("nrtrie", "⋭");
        m.put("nsc", "⊁");
        m.put("nsccue", "⋡");
        m.put("nsce", "⪰̸");
        m.put("nscr", "𝓃");
        m.put("nshortmid", "∤");
        m.put("nshortparallel", "∦");
        m.put("nsim", "≁");
        m.put("nsime", "≄");
        m.put("nsimeq", "≄");
        m.put("nsmid", "∤");
        m.put("nspar", "∦");
        m.put("nsqsube", "⋢");
        m.put("nsqsupe", "⋣");
        m.put("nsub", "⊄");
        m.put("nsubE", "⫅̸");
        m.put("nsube", "⊈");
        m.put("nsubset", "⊂⃒");
        m.put("nsubseteq", "⊈");
        m.put("nsubseteqq", "⫅̸");
        m.put("nsucc", "⊁");
        m.put("nsucceq", "⪰̸");
        m.put("nsup", "⊅");
        m.put("nsupE", "⫆̸");
        m.put("nsupe", "⊉");
        m.put("nsupset", "⊃⃒");
        m.put("nsupseteq", "⊉");
        m.put("nsupseteqq", "⫆̸");
        m.put("ntgl", "≹");
        m.put("ntilde", "ñ");
        m.put("ntlg", "≸");
        m.put("ntriangleleft", "⋪");
        m.put("ntrianglelefteq", "⋬");
        m.put("ntriangleright", "⋫");
        m.put("ntrianglerighteq", "⋭");
        m.put("nu", "ν");
        m.put("num", "#");
        m.put("numero", "№");
        m.put("numsp", " ");
        m.put("nvDash", "⊭");
        m.put("nvHarr", "⤄");
        m.put("nvap", "≍⃒");
        m.put("nvdash", "⊬");
        m.put("nvge", "≥⃒");
        m.put("nvgt", ">⃒");
        m.put("nvinfin", "⧞");
        m.put("nvlArr", "⤂");
        m.put("nvle", "≤⃒");
        m.put("nvlt", "<⃒");
        m.put("nvltrie", "⊴⃒");
        m.put("nvrArr", "⤃");
        m.put("nvrtrie", "⊵⃒");
        m.put("nvsim", "∼⃒");
        m.put("nwArr", "⇖");
        m.put("nwarhk", "⤣");
        m.put("nwarr", "↖");
        m.put("nwarrow", "↖");
        m.put("nwnear", "⤧");
        m.put("oS", "Ⓢ");
        m.put("oacute", "ó");
        m.put("oast", "⊛");
        m.put("ocir", "⊚");
        m.put("ocirc", "ô");
        m.put("ocy", "о");
        m.put("odash", "⊝");
        m.put("odblac", "ő");
        m.put("odiv", "⨸");
        m.put("odot", "⊙");
        m.put("odsold", "⦼");
        m.put("oelig", "œ");
        m.put("ofcir", "⦿");
        m.put("ofr", "𝔬");
        m.put("ogon", "˛");
        m.put("ograve", "ò");
        m.put("ogt", "⧁");
        m.put("ohbar", "⦵");
        m.put("ohm", "Ω");
        m.put("oint", "∮");
        m.put("olarr", "↺");
        m.put("olcir", "⦾");
        m.put("olcross", "⦻");
        m.put("oline", "‾");
        m.put("olt", "⧀");
        m.put("omacr", "ō");
        m.put("omega", "ω");
        m.put("omicron", "ο");
        m.put("omid", "⦶");
        m.put("ominus", "⊖");
        m.put("oopf", "𝕠");
        m.put("opar", "⦷");
        m.put("operp", "⦹");
        m.put("oplus", "⊕");
        m.put("or", "∨");
        m.put("orarr", "↻");
        m.put("ord", "⩝");
        m.put("order", "ℴ");
        m.put("orderof", "ℴ");
        m.put("ordf", "ª");
        m.put("ordm", "º");
        m.put("origof", "⊶");
        m.put("oror", "⩖");
        m.put("orslope", "⩗");
        m.put("orv", "⩛");
        m.put("oscr", "ℴ");
        m.put("oslash", "ø");
        m.put("osol", "⊘");
        m.put("otilde", "õ");
        m.put("otimes", "⊗");
        m.put("otimesas", "⨶");
        m.put("ouml", "ö");
        m.put("ovbar", "⌽");
        m.put("par", "∥");
        m.put("para", "¶");
        m.put("parallel", "∥");
        m.put("parsim", "⫳");
        m.put("parsl", "⫽");
        m.put("part", "∂");
        m.put("pcy", "п");
        m.put("percnt", "%");
        m.put("period", ".");
        m.put("permil", "‰");
        m.put("perp", "⊥");
        m.put("pertenk", "‱");
        m.put("pfr", "𝔭");
        m.put("phi", "φ");
        m.put("phiv", "ϕ");
        m.put("phmmat", "ℳ");
        m.put("phone", "☎");
        m.put("pi", "π");
        m.put("pitchfork", "⋔");
        m.put("piv", "ϖ");
        m.put("planck", "ℏ");
        m.put("planckh", "ℎ");
        m.put("plankv", "ℏ");
        m.put("plus", "+");
        m.put("plusacir", "⨣");
        m.put("plusb", "⊞");
        m.put("pluscir", "⨢");
        m.put("plusdo", "∔");
        m.put("plusdu", "⨥");
        m.put("pluse", "⩲");
        m.put("plusmn", "±");
        m.put("plussim", "⨦");
        m.put("plustwo", "⨧");
        m.put("pm", "±");
        m.put("pointint", "⨕");
        m.put("popf", "𝕡");
        m.put("pound", "£");
        m.put("pr", "≺");
        m.put("prE", "⪳");
        m.put("prap", "⪷");
        m.put("prcue", "≼");
        m.put("pre", "⪯");
        m.put("prec", "≺");
        m.put("precapprox", "⪷");
        m.put("preccurlyeq", "≼");
        m.put("preceq", "⪯");
        m.put("precnapprox", "⪹");
        m.put("precneqq", "⪵");
        m.put("precnsim", "⋨");
        m.put("precsim", "≾");
        m.put("prime", "′");
        m.put("primes", "ℙ");
        m.put("prnE", "⪵");
        m.put("prnap", "⪹");
        m.put("prnsim", "⋨");
        m.put("prod", "∏");
        m.put("profalar", "⌮");
        m.put("profline", "⌒");
        m.put("profsurf", "⌓");
        m.put("prop", "∝");
        m.put("propto", "∝");
        m.put("prsim", "≾");
        m.put("prurel", "⊰");
        m.put("pscr", "𝓅");
        m.put("psi", "ψ");
        m.put("puncsp", " ");
        m.put("qfr", "𝔮");
        m.put("qint", "⨌");
        m.put("qopf", "𝕢");
        m.put("qprime", "⁗");
        m.put("qscr", "𝓆");
        m.put("quaternions", "ℍ");
        m.put("quatint", "⨖");
        m.put("quest", "?");
        m.put("questeq", "≟");
        m.put("quot", "\"");
        m.put("rAarr", "⇛");
        m.put("rArr", "⇒");
        m.put("rAtail", "⤜");
        m.put("rBarr", "⤏");
        m.put("rHar", "⥤");
        m.put("race", "∽̱");
        m.put("racute", "ŕ");
        m.put("radic", "√");
        m.put("raemptyv", "⦳");
        m.put("rang", "⟩");
        m.put("rangd", "⦒");
        m.put("range", "⦥");
        m.put("rangle", "⟩");
        m.put("raquo", "»");
        m.put("rarr", "→");
        m.put("rarrap", "⥵");
        m.put("rarrb", "⇥");
        m.put("rarrbfs", "⤠");
        m.put("rarrc", "⤳");
        m.put("rarrfs", "⤞");
        m.put("rarrhk", "↪");
        m.put("rarrlp", "↬");
        m.put("rarrpl", "⥅");
        m.put("rarrsim", "⥴");
        m.put("rarrtl", "↣");
        m.put("rarrw", "↝");
        m.put("ratail", "⤚");
        m.put("ratio", "∶");
        m.put("rationals", "ℚ");
        m.put("rbarr", "⤍");
        m.put("rbbrk", "❳");
        m.put("rbrace", "}");
        m.put("rbrack", "]");
        m.put("rbrke", "⦌");
        m.put("rbrksld", "⦎");
        m.put("rbrkslu", "⦐");
        m.put("rcaron", "ř");
        m.put("rcedil", "ŗ");
        m.put("rceil", "⌉");
        m.put("rcub", "}");
        m.put("rcy", "р");
        m.put("rdca", "⤷");
        m.put("rdldhar", "⥩");
        m.put("rdquo", "”");
        m.put("rdquor", "”");
        m.put("rdsh", "↳");
        m.put("real", "ℜ");
        m.put("realine", "ℛ");
        m.put("realpart", "ℜ");
        m.put("reals", "ℝ");
        m.put("rect", "▭");
        m.put("reg", "®");
        m.put("rfisht", "⥽");
        m.put("rfloor", "⌋");
        m.put("rfr", "𝔯");
        m.put("rhard", "⇁");
        m.put("rharu", "⇀");
        m.put("rharul", "⥬");
        m.put("rho", "ρ");
        m.put("rhov", "ϱ");
        m.put("rightarrow", "→");
        m.put("rightarrowtail", "↣");
        m.put("rightharpoondown", "⇁");
        m.put("rightharpoonup", "⇀");
        m.put("rightleftarrows", "⇄");
        m.put("rightleftharpoons", "⇌");
        m.put("rightrightarrows", "⇉");
        m.put("rightsquigarrow", "↝");
        m.put("rightthreetimes", "⋌");
        m.put("ring", "˚");
        m.put("risingdotseq", "≓");
        m.put("rlarr", "⇄");
        m.put("rlhar", "⇌");
        m.put("rlm", "‏");
        m.put("rmoust", "⎱");
        m.put("rmoustache", "⎱");
        m.put("rnmid", "⫮");
        m.put("roang", "⟭");
        m.put("roarr", "⇾");
        m.put("robrk", "⟧");
        m.put("ropar", "⦆");
        m.put("ropf", "𝕣");
        m.put("roplus", "⨮");
        m.put("rotimes", "⨵");
        m.put("rpar", ")");
        m.put("rpargt", "⦔");
        m.put("rppolint", "⨒");
        m.put("rrarr", "⇉");
        m.put("rsaquo", "›");
        m.put("rscr", "𝓇");
        m.put("rsh", "↱");
        m.put("rsqb", "]");
        m.put("rsquo", "’");
        m.put("rsquor", "’");
        m.put("rthree", "⋌");
        m.put("rtimes", "⋊");
        m.put("rtri", "▹");
        m.put("rtrie", "⊵");
        m.put("rtrif", "▸");
        m.put("rtriltri", "⧎");
        m.put("ruluhar", "⥨");
        m.put("rx", "℞");
        m.put("sacute", "ś");
        m.put("sbquo", "‚");
        m.put("sc", "≻");
        m.put("scE", "⪴");
        m.put("scap", "⪸");
        m.put("scaron", "š");
        m.put("sccue", "≽");
        m.put("sce", "⪰");
        m.put("scedil", "ş");
        m.put("scirc", "ŝ");
        m.put("scnE", "⪶");
        m.put("scnap", "⪺");
        m.put("scnsim", "⋩");
        m.put("scpolint", "⨓");
        m.put("scsim", "≿");
        m.put("scy", "с");
        m.put("sdot", "⋅");
        m.put("sdotb", "⊡");
        m.put("sdote", "⩦");
        m.put("seArr", "⇘");
        m.put("searhk", "⤥");
        m.put("searr", "↘");
        m.put("searrow", "↘");
        m.put("sect", "§");
        m.put("semi", ";");
        m.put("seswar", "⤩");
        m.put("setminus", "∖");
        m.put("setmn", "∖");
        m.put("sext", "✶");
        m.put("sfr", "𝔰");
        m.put("sfrown", "⌢");
        m.put("sharp", "♯");
        m.put("shchcy", "щ");
        m.put("shcy", "ш");
        m.put("shortmid", "∣");
        m.put("shortparallel", "∥");
        m.put("shy", "­");
        m.put("sigma", "σ");
        m.put("sigmaf", "ς");
        m.put("sigmav", "ς");
        m.put("sim", "∼");
        m.put("simdot", "⩪");
        m.put("sime", "≃");
        m.put("simeq", "≃");
        m.put("simg", "⪞");
        m.put("simgE", "⪠");
        m.put("siml", "⪝");
        m.put("simlE", "⪟");
        m.put("simne", "≆");
        m.put("simplus", "⨤");
        m.put("simrarr", "⥲");
        m.put("slarr", "←");
        m.put("smallsetminus", "∖");
        m.put("smashp", "⨳");
        m.put("smeparsl", "⧤");
        m.put("smid", "∣");
        m.put("smile", "⌣");
        m.put("smt", "⪪");
        m.put("smte", "⪬");
        m.put("smtes", "⪬︀");
        m.put("softcy", "ь");
        m.put("sol", "/");
        m.put("solb", "⧄");
        m.put("solbar", "⌿");
        m.put("sopf", "𝕤");
        m.put("spades", "♠");
        m.put("spadesuit", "♠");
        m.put("spar", "∥");
        m.put("sqcap", "⊓");
        m.put("sqcaps", "⊓︀");
        m.put("sqcup", "⊔");
        m.put("sqcups", "⊔︀");
        m.put("sqsub", "⊏");
        m.put("sqsube", "⊑");
        m.put("sqsubset", "⊏");
        m.put("sqsubseteq", "⊑");
        m.put("sqsup", "⊐");
        m.put("sqsupe", "⊒");
        m.put("sqsupset", "⊐");
        m.put("sqsupseteq", "⊒");
        m.put("squ", "□");
        m.put("square", "□");
        m.put("squarf", "▪");
        m.put("squf", "▪");
        m.put("srarr", "→");
        m.put("sscr", "𝓈");
        m.put("ssetmn", "∖");
        m.put("ssmile", "⌣");
        m.put("sstarf", "⋆");
        m.put("star", "☆");
        m.put("starf", "★");
        m.put("straightepsilon", "ϵ");
        m.put("straightphi", "ϕ");
        m.put("strns", "¯");
        m.put("sub", "⊂");
        m.put("subE", "⫅");
        m.put("subdot", "⪽");
        m.put("sube", "⊆");
        m.put("subedot", "⫃");
        m.put("submult", "⫁");
        m.put("subnE", "⫋");
        m.put("subne", "⊊");
        m.put("subplus", "⪿");
        m.put("subrarr", "⥹");
        m.put("subset", "⊂");
        m.put("subseteq", "⊆");
        m.put("subseteqq", "⫅");
        m.put("subsetneq", "⊊");
        m.put("subsetneqq", "⫋");
        m.put("subsim", "⫇");
        m.put("subsub", "⫕");
        m.put("subsup", "⫓");
        m.put("succ", "≻");
        m.put("succapprox", "⪸");
        m.put("succcurlyeq", "≽");
        m.put("succeq", "⪰");
        m.put("succnapprox", "⪺");
        m.put("succneqq", "⪶");
        m.put("succnsim", "⋩");
        m.put("succsim", "≿");
        m.put("sum", "∑");
        m.put("sung", "♪");
        m.put("sup1", "¹");
        m.put("sup2", "²");
        m.put("sup3", "³");
        m.put("sup", "⊃");
        m.put("supE", "⫆");
        m.put("supdot", "⪾");
        m.put("supdsub", "⫘");
        m.put("supe", "⊇");
        m.put("supedot", "⫄");
        m.put("suphsol", "⟉");
        m.put("suphsub", "⫗");
        m.put("suplarr", "⥻");
        m.put("supmult", "⫂");
        m.put("supnE", "⫌");
        m.put("supne", "⊋");
        m.put("supplus", "⫀");
        m.put("supset", "⊃");
        m.put("supseteq", "⊇");
        m.put("supseteqq", "⫆");
        m.put("supsetneq", "⊋");
        m.put("supsetneqq", "⫌");
        m.put("supsim", "⫈");
        m.put("supsub", "⫔");
        m.put("supsup", "⫖");
        m.put("swArr", "⇙");
        m.put("swarhk", "⤦");
        m.put("swarr", "↙");
        m.put("swarrow", "↙");
        m.put("swnwar", "⤪");
        m.put("szlig", "ß");
        m.put("target", "⌖");
        m.put("tau", "τ");
        m.put("tbrk", "⎴");
        m.put("tcaron", "ť");
        m.put("tcedil", "ţ");
        m.put("tcy", "т");
        m.put("tdot", "⃛");
        m.put("telrec", "⌕");
        m.put("tfr", "𝔱");
        m.put("there4", "∴");
        m.put("therefore", "∴");
        m.put("theta", "θ");
        m.put("thetasym", "ϑ");
        m.put("thetav", "ϑ");
        m.put("thickapprox", "≈");
        m.put("thicksim", "∼");
        m.put("thinsp", " ");
        m.put("thkap", "≈");
        m.put("thksim", "∼");
        m.put("thorn", "þ");
        m.put("tilde", "˜");
        m.put("times", "×");
        m.put("timesb", "⊠");
        m.put("timesbar", "⨱");
        m.put("timesd", "⨰");
        m.put("tint", "∭");
        m.put("toea", "⤨");
        m.put("top", "⊤");
        m.put("topbot", "⌶");
        m.put("topcir", "⫱");
        m.put("topf", "𝕥");
        m.put("topfork", "⫚");
        m.put("tosa", "⤩");
        m.put("tprime", "‴");
        m.put("trade", "™");
        m.put("triangle", "▵");
        m.put("triangledown", "▿");
        m.put("triangleleft", "◃");
        m.put("trianglelefteq", "⊴");
        m.put("triangleq", "≜");
        m.put("triangleright", "▹");
        m.put("trianglerighteq", "⊵");
        m.put("tridot", "◬");
        m.put("trie", "≜");
        m.put("triminus", "⨺");
        m.put("triplus", "⨹");
        m.put("trisb", "⧍");
        m.put("tritime", "⨻");
        m.put("trpezium", "⏢");
        m.put("tscr", "𝓉");
        m.put("tscy", "ц");
        m.put("tshcy", "ћ");
        m.put("tstrok", "ŧ");
        m.put("twixt", "≬");
        m.put("twoheadleftarrow", "↞");
        m.put("twoheadrightarrow", "↠");
        m.put("uArr", "⇑");
        m.put("uHar", "⥣");
        m.put("uacute", "ú");
        m.put("uarr", "↑");
        m.put("ubrcy", "ў");
        m.put("ubreve", "ŭ");
        m.put("ucirc", "û");
        m.put("ucy", "у");
        m.put("udarr", "⇅");
        m.put("udblac", "ű");
        m.put("udhar", "⥮");
        m.put("ufisht", "⥾");
        m.put("ufr", "𝔲");
        m.put("ugrave", "ù");
        m.put("uharl", "↿");
        m.put("uharr", "↾");
        m.put("uhblk", "▀");
        m.put("ulcorn", "⌜");
        m.put("ulcorner", "⌜");
        m.put("ulcrop", "⌏");
        m.put("ultri", "◸");
        m.put("umacr", "ū");
        m.put("uml", "¨");
        m.put("uogon", "ų");
        m.put("uopf", "𝕦");
        m.put("uparrow", "↑");
        m.put("updownarrow", "↕");
        m.put("upharpoonleft", "↿");
        m.put("upharpoonright", "↾");
        m.put("uplus", "⊎");
        m.put("upsi", "υ");
        m.put("upsih", "ϒ");
        m.put("upsilon", "υ");
        m.put("upuparrows", "⇈");
        m.put("urcorn", "⌝");
        m.put("urcorner", "⌝");
        m.put("urcrop", "⌎");
        m.put("uring", "ů");
        m.put("urtri", "◹");
        m.put("uscr", "𝓊");
        m.put("utdot", "⋰");
        m.put("utilde", "ũ");
        m.put("utri", "▵");
        m.put("utrif", "▴");
        m.put("uuarr", "⇈");
        m.put("uuml", "ü");
        m.put("uwangle", "⦧");
        m.put("vArr", "⇕");
        m.put("vBar", "⫨");
        m.put("vBarv", "⫩");
        m.put("vDash", "⊨");
        m.put("vangrt", "⦜");
        m.put("varepsilon", "ϵ");
        m.put("varkappa", "ϰ");
        m.put("varnothing", "∅");
        m.put("varphi", "ϕ");
        m.put("varpi", "ϖ");
        m.put("varpropto", "∝");
        m.put("varr", "↕");
        m.put("varrho", "ϱ");
        m.put("varsigma", "ς");
        m.put("varsubsetneq", "⊊︀");
        m.put("varsubsetneqq", "⫋︀");
        m.put("varsupsetneq", "⊋︀");
        m.put("varsupsetneqq", "⫌︀");
        m.put("vartheta", "ϑ");
        m.put("vartriangleleft", "⊲");
        m.put("vartriangleright", "⊳");
        m.put("vcy", "в");
        m.put("vdash", "⊢");
        m.put("vee", "∨");
        m.put("veebar", "⊻");
        m.put("veeeq", "≚");
        m.put("vellip", "⋮");
        m.put("verbar", "|");
        m.put("vert", "|");
        m.put("vfr", "𝔳");
        m.put("vltri", "⊲");
        m.put("vnsub", "⊂⃒");
        m.put("vnsup", "⊃⃒");
        m.put("vopf", "𝕧");
        m.put("vprop", "∝");
        m.put("vrtri", "⊳");
        m.put("vscr", "𝓋");
        m.put("vsubnE", "⫋︀");
        m.put("vsubne", "⊊︀");
        m.put("vsupnE", "⫌︀");
        m.put("vsupne", "⊋︀");
        m.put("vzigzag", "⦚");
        m.put("wcirc", "ŵ");
        m.put("wedbar", "⩟");
        m.put("wedge", "∧");
        m.put("wedgeq", "≙");
        m.put("weierp", "℘");
        m.put("wfr", "𝔴");
        m.put("wopf", "𝕨");
        m.put("wp", "℘");
        m.put("wr", "≀");
        m.put("wreath", "≀");
        m.put("wscr", "𝓌");
        m.put("xcap", "⋂");
        m.put("xcirc", "◯");
        m.put("xcup", "⋃");
        m.put("xdtri", "▽");
        m.put("xfr", "𝔵");
        m.put("xhArr", "⟺");
        m.put("xharr", "⟷");
        m.put("xi", "ξ");
        m.put("xlArr", "⟸");
        m.put("xlarr", "⟵");
        m.put("xmap", "⟼");
        m.put("xnis", "⋻");
        m.put("xodot", "⨀");
        m.put("xopf", "𝕩");
        m.put("xoplus", "⨁");
        m.put("xotime", "⨂");
        m.put("xrArr", "⟹");
        m.put("xrarr", "⟶");
        m.put("xscr", "𝓍");
        m.put("xsqcup", "⨆");
        m.put("xuplus", "⨄");
        m.put("xutri", "△");
        m.put("xvee", "⋁");
        m.put("xwedge", "⋀");
        m.put("yacute", "ý");
        m.put("yacy", "я");
        m.put("ycirc", "ŷ");
        m.put("ycy", "ы");
        m.put("yen", "¥");
        m.put("yfr", "𝔶");
        m.put("yicy", "ї");
        m.put("yopf", "𝕪");
        m.put("yscr", "𝓎");
        m.put("yucy", "ю");
        m.put("yuml", "ÿ");
        m.put("zacute", "ź");
        m.put("zcaron", "ž");
        m.put("zcy", "з");
        m.put("zdot", "ż");
        m.put("zeetrf", "ℨ");
        m.put("zeta", "ζ");
        m.put("zfr", "𝔷");
        m.put("zhcy", "ж");
        m.put("zigrarr", "⇝");
        m.put("zopf", "𝕫");
        m.put("zscr", "𝓏");
        m.put("zwj", "‍");
        m.put("zwnj", "‌");
        HTML_ENTITY_TABLE = Collections.unmodifiableMap(m);
    }

    /** A parsed reference. {@code end} is the index just past the closing
     * ';'. When {@code resolved} is true the decoded string lives in
     * {@code value}; otherwise the caller must emit the original
     * text[start..end) verbatim. */
    private static final class Reference {
        int end;
        String value;
        boolean resolved;
    }

    /** Hand-rolled matcher for the grammar
     * {@code &(#[xX][0-9a-fA-F]+|#[0-9]+|[A-Za-z][A-Za-z0-9]*);}.
     *
     * <p>Given that text[start] == '&amp;', attempt to parse a well-formed
     * reference. Returns true and fills {@code ref} on success (which
     * includes "resolved = false" for unknown / unsafe references — the
     * caller then keeps the original text whole). Returns false when no
     * reference grammar matches at all. */
    private static boolean parseReference(String text, int start, Reference ref) {
        final int n = text.length();
        int j = start + 1; // just past '&'
        if (j >= n) {
            return false;
        }

        // Identify the body grammar and scan its trailing index into j.
        if (text.charAt(j) == '#') {
            j++;
            if (j >= n) {
                return false;
            }
            boolean hex = text.charAt(j) == 'x' || text.charAt(j) == 'X';
            if (hex) {
                j++;
            }
            int digitsStart = j;
            while (j < n && entityDigit(text.charAt(j), hex)) {
                j++;
            }
            if (j == digitsStart) {
                return false; // '#' / '#x' with no digits is not a reference
            }
        } else if (asciiLetter(text.charAt(j))) {
            j++;
            while (j < n && asciiAlnum(text.charAt(j))) {
                j++;
            }
        } else {
            return false; // '&' not followed by '#' or a letter
        }

        // The body must be terminated by ';'.
        if (j >= n || text.charAt(j) != ';') {
            return false;
        }

        ref.end = j + 1;
        resolveBody(text.substring(start + 1, j), ref);
        return true;
    }

    /** Resolve one reference body (name, or "#digits") to its character, or
     * leave the reference unresolved when it is unrecognized / unsafe.
     *
     * <p>The numeric accumulator saturates just above U+10FFFF instead of
     * running dry on absurd digit runs — one guard covering both the
     * out-of-range check and the overflow check that u32::from_str_radix
     * performs in the Rust port. Lone surrogates (U+D800..U+DFFF) get their
     * own explicit check (appendCodePoint would happily emit them). */
    private static void resolveBody(String body, Reference ref) {
        if (body.charAt(0) == '#') {
            boolean hex = body.length() >= 2
                    && (body.charAt(1) == 'x' || body.charAt(1) == 'X');
            String digits = hex ? body.substring(2) : body.substring(1);

            boolean overflow = false;
            long acc = 0;
            for (int k = 0; k < digits.length(); k++) {
                if (!overflow) {
                    acc = acc * (hex ? 16L : 10L) + digitValue(digits.charAt(k));
                    if (acc > 0x10FFFF) {
                        overflow = true; // saturate; keep scanning digits
                    }
                }
            }

            if (overflow || acc > 0x10FFFF
                    || (acc >= 0xD800L && acc <= 0xDFFFL)) {
                ref.resolved = false; // out of range or a lone surrogate
                return;
            }
            ref.value = new StringBuilder().appendCodePoint((int) acc).toString();
            ref.resolved = true;
            return;
        }

        // Named reference: one hash lookup over the full WHATWG table.
        String value = HTML_ENTITY_TABLE.get(body);
        if (value != null) {
            ref.value = value;
            ref.resolved = true;
        } else {
            ref.resolved = false; // unknown name — keep the original text whole
        }
    }

    /** true when c is a valid digit for the radix (10 or 16). */
    private static boolean entityDigit(char c, boolean hex) {
        if (c >= '0' && c <= '9') {
            return true;
        }
        return hex && ((c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
    }

    /** Numeric value of one hex/decimal digit (caller guarantees
     * entityDigit). */
    static int digitValue(char c) {
        if (c <= '9') {
            return c - '0';
        }
        return c <= 'F' ? c - 'A' + 10 : c - 'a' + 10;
    }

    /** ASCII [A-Za-z]. */
    private static boolean asciiLetter(char c) {
        return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
    }

    /** ASCII [A-Za-z0-9]. */
    private static boolean asciiAlnum(char c) {
        return asciiLetter(c) || (c >= '0' && c <= '9');
    }
}

Also available in 13 other languages

Every CosmoDev tool ships its pure logic in TypeScript (web) and Go (CLI), with authored implementations in a dozen-plus languages — the same contract, ported. Compare all languages side by side →