001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.text.translate; 018 019import java.util.Collections; 020import java.util.HashMap; 021import java.util.Map; 022import java.util.Map.Entry; 023import java.util.stream.Collectors; 024 025/** 026 * Class holding various entity data for HTML and XML - generally for use with 027 * the LookupTranslator. 028 * All Maps are generated using {@code java.util.Collections.unmodifiableMap()}. 029 * 030 * @since 1.0 031 */ 032public class EntityArrays { 033 034 /** 035 * A Map<CharSequence, CharSequence> to escape 036 * <a href="https://secure.wikimedia.org/wikipedia/en/wiki/ISO/IEC_8859-1">ISO-8859-1</a> 037 * characters to their named HTML 3.x equivalents. 038 */ 039 public static final Map<CharSequence, CharSequence> ISO8859_1_ESCAPE; 040 static { 041 final Map<CharSequence, CharSequence> initialMap = new HashMap<>(); 042 initialMap.put("\u00A0", " "); // non-breaking space 043 initialMap.put("\u00A1", "¡"); // inverted exclamation mark 044 initialMap.put("\u00A2", "¢"); // cent sign 045 initialMap.put("\u00A3", "£"); // pound sign 046 initialMap.put("\u00A4", "¤"); // currency sign 047 initialMap.put("\u00A5", "¥"); // yen sign = yuan sign 048 initialMap.put("\u00A6", "¦"); // broken bar = broken vertical bar 049 initialMap.put("\u00A7", "§"); // section sign 050 initialMap.put("\u00A8", "¨"); // dieresis = spacing dieresis 051 initialMap.put("\u00A9", "©"); // © - copyright sign 052 initialMap.put("\u00AA", "ª"); // feminine ordinal indicator 053 initialMap.put("\u00AB", "«"); // left-pointing double angle quotation mark = left pointing guillemet 054 initialMap.put("\u00AC", "¬"); // not sign 055 initialMap.put("\u00AD", "­"); // soft hyphen = discretionary hyphen 056 initialMap.put("\u00AE", "®"); // ® - registered trademark sign 057 initialMap.put("\u00AF", "¯"); // macron = spacing macron = overline = APL overbar 058 initialMap.put("\u00B0", "°"); // degree sign 059 initialMap.put("\u00B1", "±"); // plus-minus sign = plus-or-minus sign 060 initialMap.put("\u00B2", "²"); // superscript two = superscript digit two = squared 061 initialMap.put("\u00B3", "³"); // superscript three = superscript digit three = cubed 062 initialMap.put("\u00B4", "´"); // acute accent = spacing acute 063 initialMap.put("\u00B5", "µ"); // micro sign 064 initialMap.put("\u00B6", "¶"); // pilcrow sign = paragraph sign 065 initialMap.put("\u00B7", "·"); // middle dot = Georgian comma = Greek middle dot 066 initialMap.put("\u00B8", "¸"); // cedilla = spacing cedilla 067 initialMap.put("\u00B9", "¹"); // superscript one = superscript digit one 068 initialMap.put("\u00BA", "º"); // masculine ordinal indicator 069 initialMap.put("\u00BB", "»"); // right-pointing double angle quotation mark = right pointing guillemet 070 initialMap.put("\u00BC", "¼"); // vulgar fraction one quarter = fraction one quarter 071 initialMap.put("\u00BD", "½"); // vulgar fraction one half = fraction one half 072 initialMap.put("\u00BE", "¾"); // vulgar fraction three quarters = fraction three quarters 073 initialMap.put("\u00BF", "¿"); // inverted question mark = turned question mark 074 initialMap.put("\u00C0", "À"); // À - uppercase A, grave accent 075 initialMap.put("\u00C1", "Á"); // Á - uppercase A, acute accent 076 initialMap.put("\u00C2", "Â"); //  - uppercase A, circumflex accent 077 initialMap.put("\u00C3", "Ã"); // à - uppercase A, tilde 078 initialMap.put("\u00C4", "Ä"); // Ä - uppercase A, umlaut 079 initialMap.put("\u00C5", "Å"); // � - uppercase A, ring 080 initialMap.put("\u00C6", "Æ"); // Æ - uppercase AE 081 initialMap.put("\u00C7", "Ç"); // Ç - uppercase C, cedilla 082 initialMap.put("\u00C8", "È"); // È - uppercase E, grave accent 083 initialMap.put("\u00C9", "É"); // É - uppercase E, acute accent 084 initialMap.put("\u00CA", "Ê"); // Ê - uppercase E, circumflex accent 085 initialMap.put("\u00CB", "Ë"); // Ë - uppercase E, umlaut 086 initialMap.put("\u00CC", "Ì"); // Ì - uppercase I, grave accent 087 initialMap.put("\u00CD", "Í"); // Í - uppercase I, acute accent 088 initialMap.put("\u00CE", "Î"); // Î - uppercase I, circumflex accent 089 initialMap.put("\u00CF", "Ï"); // Ï - uppercase I, umlaut 090 initialMap.put("\u00D0", "Ð"); // Ð - uppercase Eth, Icelandic 091 initialMap.put("\u00D1", "Ñ"); // Ñ - uppercase N, tilde 092 initialMap.put("\u00D2", "Ò"); // Ò - uppercase O, grave accent 093 initialMap.put("\u00D3", "Ó"); // Ó - uppercase O, acute accent 094 initialMap.put("\u00D4", "Ô"); // Ô - uppercase O, circumflex accent 095 initialMap.put("\u00D5", "Õ"); // Õ - uppercase O, tilde 096 initialMap.put("\u00D6", "Ö"); // Ö - uppercase O, umlaut 097 initialMap.put("\u00D7", "×"); // multiplication sign 098 initialMap.put("\u00D8", "Ø"); // Ø - uppercase O, slash 099 initialMap.put("\u00D9", "Ù"); // Ù - uppercase U, grave accent 100 initialMap.put("\u00DA", "Ú"); // Ú - uppercase U, acute accent 101 initialMap.put("\u00DB", "Û"); // Û - uppercase U, circumflex accent 102 initialMap.put("\u00DC", "Ü"); // Ü - uppercase U, umlaut 103 initialMap.put("\u00DD", "Ý"); // Ý - uppercase Y, acute accent 104 initialMap.put("\u00DE", "Þ"); // Þ - uppercase THORN, Icelandic 105 initialMap.put("\u00DF", "ß"); // ß - lowercase sharps, German 106 initialMap.put("\u00E0", "à"); // à - lowercase a, grave accent 107 initialMap.put("\u00E1", "á"); // á - lowercase a, acute accent 108 initialMap.put("\u00E2", "â"); // â - lowercase a, circumflex accent 109 initialMap.put("\u00E3", "ã"); // ã - lowercase a, tilde 110 initialMap.put("\u00E4", "ä"); // ä - lowercase a, umlaut 111 initialMap.put("\u00E5", "å"); // å - lowercase a, ring 112 initialMap.put("\u00E6", "æ"); // æ - lowercase ae 113 initialMap.put("\u00E7", "ç"); // ç - lowercase c, cedilla 114 initialMap.put("\u00E8", "è"); // è - lowercase e, grave accent 115 initialMap.put("\u00E9", "é"); // é - lowercase e, acute accent 116 initialMap.put("\u00EA", "ê"); // ê - lowercase e, circumflex accent 117 initialMap.put("\u00EB", "ë"); // ë - lowercase e, umlaut 118 initialMap.put("\u00EC", "ì"); // ì - lowercase i, grave accent 119 initialMap.put("\u00ED", "í"); // í - lowercase i, acute accent 120 initialMap.put("\u00EE", "î"); // î - lowercase i, circumflex accent 121 initialMap.put("\u00EF", "ï"); // ï - lowercase i, umlaut 122 initialMap.put("\u00F0", "ð"); // ð - lowercase eth, Icelandic 123 initialMap.put("\u00F1", "ñ"); // ñ - lowercase n, tilde 124 initialMap.put("\u00F2", "ò"); // ò - lowercase o, grave accent 125 initialMap.put("\u00F3", "ó"); // ó - lowercase o, acute accent 126 initialMap.put("\u00F4", "ô"); // ô - lowercase o, circumflex accent 127 initialMap.put("\u00F5", "õ"); // õ - lowercase o, tilde 128 initialMap.put("\u00F6", "ö"); // ö - lowercase o, umlaut 129 initialMap.put("\u00F7", "÷"); // division sign 130 initialMap.put("\u00F8", "ø"); // ø - lowercase o, slash 131 initialMap.put("\u00F9", "ù"); // ù - lowercase u, grave accent 132 initialMap.put("\u00FA", "ú"); // ú - lowercase u, acute accent 133 initialMap.put("\u00FB", "û"); // û - lowercase u, circumflex accent 134 initialMap.put("\u00FC", "ü"); // ü - lowercase u, umlaut 135 initialMap.put("\u00FD", "ý"); // ý - lowercase y, acute accent 136 initialMap.put("\u00FE", "þ"); // þ - lowercase thorn, Icelandic 137 initialMap.put("\u00FF", "ÿ"); // ÿ - lowercase y, umlaut 138 ISO8859_1_ESCAPE = Collections.unmodifiableMap(initialMap); 139 } 140 141 /** 142 * Reverse of {@link #ISO8859_1_ESCAPE} for unescaping purposes. 143 */ 144 public static final Map<CharSequence, CharSequence> ISO8859_1_UNESCAPE; 145 146 static { 147 ISO8859_1_UNESCAPE = Collections.unmodifiableMap(invert(ISO8859_1_ESCAPE)); 148 } 149 150 /** 151 * A Map<CharSequence, CharSequence> to escape additional 152 * <a href="http://www.w3.org/TR/REC-html40/sgml/entities.html">character entity 153 * references</a>. Note that this must be used with {@link #ISO8859_1_ESCAPE} to get the full list of 154 * HTML 4.0 character entities. 155 */ 156 public static final Map<CharSequence, CharSequence> HTML40_EXTENDED_ESCAPE; 157 158 static { 159 final Map<CharSequence, CharSequence> initialMap = new HashMap<>(); 160 // <!-- Latin Extended-B --> 161 initialMap.put("\u0192", "ƒ"); // latin small f with hook = function= florin, U+0192 ISOtech --> 162 // <!-- Greek --> 163 initialMap.put("\u0391", "Α"); // greek capital letter alpha, U+0391 --> 164 initialMap.put("\u0392", "Β"); // greek capital letter beta, U+0392 --> 165 initialMap.put("\u0393", "Γ"); // greek capital letter gamma,U+0393 ISOgrk3 --> 166 initialMap.put("\u0394", "Δ"); // greek capital letter delta,U+0394 ISOgrk3 --> 167 initialMap.put("\u0395", "Ε"); // greek capital letter epsilon, U+0395 --> 168 initialMap.put("\u0396", "Ζ"); // greek capital letter zeta, U+0396 --> 169 initialMap.put("\u0397", "Η"); // greek capital letter eta, U+0397 --> 170 initialMap.put("\u0398", "Θ"); // greek capital letter theta,U+0398 ISOgrk3 --> 171 initialMap.put("\u0399", "Ι"); // greek capital letter iota, U+0399 --> 172 initialMap.put("\u039A", "Κ"); // greek capital letter kappa, U+039A --> 173 initialMap.put("\u039B", "Λ"); // greek capital letter lambda,U+039B ISOgrk3 --> 174 initialMap.put("\u039C", "Μ"); // greek capital letter mu, U+039C --> 175 initialMap.put("\u039D", "Ν"); // greek capital letter nu, U+039D --> 176 initialMap.put("\u039E", "Ξ"); // greek capital letter xi, U+039E ISOgrk3 --> 177 initialMap.put("\u039F", "Ο"); // greek capital letter omicron, U+039F --> 178 initialMap.put("\u03A0", "Π"); // greek capital letter pi, U+03A0 ISOgrk3 --> 179 initialMap.put("\u03A1", "Ρ"); // greek capital letter rho, U+03A1 --> 180 // <!-- there is no Sigmaf, and no U+03A2 character either --> 181 initialMap.put("\u03A3", "Σ"); // greek capital letter sigma,U+03A3 ISOgrk3 --> 182 initialMap.put("\u03A4", "Τ"); // greek capital letter tau, U+03A4 --> 183 initialMap.put("\u03A5", "Υ"); // greek capital letter upsilon,U+03A5 ISOgrk3 --> 184 initialMap.put("\u03A6", "Φ"); // greek capital letter phi,U+03A6 ISOgrk3 --> 185 initialMap.put("\u03A7", "Χ"); // greek capital letter chi, U+03A7 --> 186 initialMap.put("\u03A8", "Ψ"); // greek capital letter psi,U+03A8 ISOgrk3 --> 187 initialMap.put("\u03A9", "Ω"); // greek capital letter omega,U+03A9 ISOgrk3 --> 188 initialMap.put("\u03B1", "α"); // greek small letter alpha,U+03B1 ISOgrk3 --> 189 initialMap.put("\u03B2", "β"); // greek small letter beta, U+03B2 ISOgrk3 --> 190 initialMap.put("\u03B3", "γ"); // greek small letter gamma,U+03B3 ISOgrk3 --> 191 initialMap.put("\u03B4", "δ"); // greek small letter delta,U+03B4 ISOgrk3 --> 192 initialMap.put("\u03B5", "ε"); // greek small letter epsilon,U+03B5 ISOgrk3 --> 193 initialMap.put("\u03B6", "ζ"); // greek small letter zeta, U+03B6 ISOgrk3 --> 194 initialMap.put("\u03B7", "η"); // greek small letter eta, U+03B7 ISOgrk3 --> 195 initialMap.put("\u03B8", "θ"); // greek small letter theta,U+03B8 ISOgrk3 --> 196 initialMap.put("\u03B9", "ι"); // greek small letter iota, U+03B9 ISOgrk3 --> 197 initialMap.put("\u03BA", "κ"); // greek small letter kappa,U+03BA ISOgrk3 --> 198 initialMap.put("\u03BB", "λ"); // greek small letter lambda,U+03BB ISOgrk3 --> 199 initialMap.put("\u03BC", "μ"); // greek small letter mu, U+03BC ISOgrk3 --> 200 initialMap.put("\u03BD", "ν"); // greek small letter nu, U+03BD ISOgrk3 --> 201 initialMap.put("\u03BE", "ξ"); // greek small letter xi, U+03BE ISOgrk3 --> 202 initialMap.put("\u03BF", "ο"); // greek small letter omicron, U+03BF NEW --> 203 initialMap.put("\u03C0", "π"); // greek small letter pi, U+03C0 ISOgrk3 --> 204 initialMap.put("\u03C1", "ρ"); // greek small letter rho, U+03C1 ISOgrk3 --> 205 initialMap.put("\u03C2", "ς"); // greek small letter final sigma,U+03C2 ISOgrk3 --> 206 initialMap.put("\u03C3", "σ"); // greek small letter sigma,U+03C3 ISOgrk3 --> 207 initialMap.put("\u03C4", "τ"); // greek small letter tau, U+03C4 ISOgrk3 --> 208 initialMap.put("\u03C5", "υ"); // greek small letter upsilon,U+03C5 ISOgrk3 --> 209 initialMap.put("\u03C6", "φ"); // greek small letter phi, U+03C6 ISOgrk3 --> 210 initialMap.put("\u03C7", "χ"); // greek small letter chi, U+03C7 ISOgrk3 --> 211 initialMap.put("\u03C8", "ψ"); // greek small letter psi, U+03C8 ISOgrk3 --> 212 initialMap.put("\u03C9", "ω"); // greek small letter omega,U+03C9 ISOgrk3 --> 213 initialMap.put("\u03D1", "ϑ"); // greek small letter theta symbol,U+03D1 NEW --> 214 initialMap.put("\u03D2", "ϒ"); // greek upsilon with hook symbol,U+03D2 NEW --> 215 initialMap.put("\u03D6", "ϖ"); // greek pi symbol, U+03D6 ISOgrk3 --> 216 // <!-- General Punctuation --> 217 initialMap.put("\u2022", "•"); // bullet = black small circle,U+2022 ISOpub --> 218 // <!-- bullet is NOT the same as bullet operator, U+2219 --> 219 initialMap.put("\u2026", "…"); // horizontal ellipsis = three dot leader,U+2026 ISOpub --> 220 initialMap.put("\u2032", "′"); // prime = minutes = feet, U+2032 ISOtech --> 221 initialMap.put("\u2033", "″"); // double prime = seconds = inches,U+2033 ISOtech --> 222 initialMap.put("\u203E", "‾"); // overline = spacing overscore,U+203E NEW --> 223 initialMap.put("\u2044", "⁄"); // fraction slash, U+2044 NEW --> 224 // <!-- Letterlike Symbols --> 225 initialMap.put("\u2118", "℘"); // script capital P = power set= Weierstrass p, U+2118 ISOamso --> 226 initialMap.put("\u2111", "ℑ"); // blackletter capital I = imaginary part,U+2111 ISOamso --> 227 initialMap.put("\u211C", "ℜ"); // blackletter capital R = real part symbol,U+211C ISOamso --> 228 initialMap.put("\u2122", "™"); // trade mark sign, U+2122 ISOnum --> 229 initialMap.put("\u2135", "ℵ"); // alef symbol = first transfinite cardinal,U+2135 NEW --> 230 // <!-- alef symbol is NOT the same as hebrew letter alef,U+05D0 although the 231 // same glyph could be used to depict both characters --> 232 // <!-- Arrows --> 233 initialMap.put("\u2190", "←"); // leftwards arrow, U+2190 ISOnum --> 234 initialMap.put("\u2191", "↑"); // upwards arrow, U+2191 ISOnum--> 235 initialMap.put("\u2192", "→"); // rightwards arrow, U+2192 ISOnum --> 236 initialMap.put("\u2193", "↓"); // downwards arrow, U+2193 ISOnum --> 237 initialMap.put("\u2194", "↔"); // left right arrow, U+2194 ISOamsa --> 238 initialMap.put("\u21B5", "↵"); // downwards arrow with corner leftwards= carriage return, U+21B5 NEW --> 239 initialMap.put("\u21D0", "⇐"); // leftwards double arrow, U+21D0 ISOtech --> 240 // <!-- ISO 10646 does not say that lArr is the same as the 'is implied by' 241 // arrow but also does not have any other character for that function. 242 // So ? lArr canbe used for 'is implied by' as ISOtech suggests --> 243 initialMap.put("\u21D1", "⇑"); // upwards double arrow, U+21D1 ISOamsa --> 244 initialMap.put("\u21D2", "⇒"); // rightwards double arrow,U+21D2 ISOtech --> 245 // <!-- ISO 10646 does not say this is the 'implies' character but does not 246 // have another character with this function so ?rArr can be used for 247 // 'implies' as ISOtech suggests --> 248 initialMap.put("\u21D3", "⇓"); // downwards double arrow, U+21D3 ISOamsa --> 249 initialMap.put("\u21D4", "⇔"); // left right double arrow,U+21D4 ISOamsa --> 250 // <!-- Mathematical Operators --> 251 initialMap.put("\u2200", "∀"); // for all, U+2200 ISOtech --> 252 initialMap.put("\u2202", "∂"); // partial differential, U+2202 ISOtech --> 253 initialMap.put("\u2203", "∃"); // there exists, U+2203 ISOtech --> 254 initialMap.put("\u2205", "∅"); // empty set = null set = diameter,U+2205 ISOamso --> 255 initialMap.put("\u2207", "∇"); // nabla = backward difference,U+2207 ISOtech --> 256 initialMap.put("\u2208", "∈"); // element of, U+2208 ISOtech --> 257 initialMap.put("\u2209", "∉"); // not an element of, U+2209 ISOtech --> 258 initialMap.put("\u220B", "∋"); // contains as member, U+220B ISOtech --> 259 // <!-- should there be a more memorable name than 'ni'? --> 260 initialMap.put("\u220F", "∏"); // n-ary product = product sign,U+220F ISOamsb --> 261 // <!-- prod is NOT the same character as U+03A0 'greek capital letter pi' 262 // though the same glyph might be used for both --> 263 initialMap.put("\u2211", "∑"); // n-ary summation, U+2211 ISOamsb --> 264 // <!-- sum is NOT the same character as U+03A3 'greek capital letter sigma' 265 // though the same glyph might be used for both --> 266 initialMap.put("\u2212", "−"); // minus sign, U+2212 ISOtech --> 267 initialMap.put("\u2217", "∗"); // asterisk operator, U+2217 ISOtech --> 268 initialMap.put("\u221A", "√"); // square root = radical sign,U+221A ISOtech --> 269 initialMap.put("\u221D", "∝"); // proportional to, U+221D ISOtech --> 270 initialMap.put("\u221E", "∞"); // infinity, U+221E ISOtech --> 271 initialMap.put("\u2220", "∠"); // angle, U+2220 ISOamso --> 272 initialMap.put("\u2227", "∧"); // logical and = wedge, U+2227 ISOtech --> 273 initialMap.put("\u2228", "∨"); // logical or = vee, U+2228 ISOtech --> 274 initialMap.put("\u2229", "∩"); // intersection = cap, U+2229 ISOtech --> 275 initialMap.put("\u222A", "∪"); // union = cup, U+222A ISOtech --> 276 initialMap.put("\u222B", "∫"); // integral, U+222B ISOtech --> 277 initialMap.put("\u2234", "∴"); // therefore, U+2234 ISOtech --> 278 initialMap.put("\u223C", "∼"); // tilde operator = varies with = similar to,U+223C ISOtech --> 279 // <!-- tilde operator is NOT the same character as the tilde, U+007E,although 280 // the same glyph might be used to represent both --> 281 initialMap.put("\u2245", "≅"); // approximately equal to, U+2245 ISOtech --> 282 initialMap.put("\u2248", "≈"); // almost equal to = asymptotic to,U+2248 ISOamsr --> 283 initialMap.put("\u2260", "≠"); // not equal to, U+2260 ISOtech --> 284 initialMap.put("\u2261", "≡"); // identical to, U+2261 ISOtech --> 285 initialMap.put("\u2264", "≤"); // less-than or equal to, U+2264 ISOtech --> 286 initialMap.put("\u2265", "≥"); // greater-than or equal to,U+2265 ISOtech --> 287 initialMap.put("\u2282", "⊂"); // subset of, U+2282 ISOtech --> 288 initialMap.put("\u2283", "⊃"); // superset of, U+2283 ISOtech --> 289 // <!-- note that nsup, 'not a superset of, U+2283' is not covered by the 290 // Symbol font encoding and is not included. Should it be, for symmetry? 291 // It is in ISOamsn -->, 292 initialMap.put("\u2284", "⊄"); // not a subset of, U+2284 ISOamsn --> 293 initialMap.put("\u2286", "⊆"); // subset of or equal to, U+2286 ISOtech --> 294 initialMap.put("\u2287", "⊇"); // superset of or equal to,U+2287 ISOtech --> 295 initialMap.put("\u2295", "⊕"); // circled plus = direct sum,U+2295 ISOamsb --> 296 initialMap.put("\u2297", "⊗"); // circled times = vector product,U+2297 ISOamsb --> 297 initialMap.put("\u22A5", "⊥"); // up tack = orthogonal to = perpendicular,U+22A5 ISOtech --> 298 initialMap.put("\u22C5", "⋅"); // dot operator, U+22C5 ISOamsb --> 299 // <!-- dot operator is NOT the same character as U+00B7 middle dot --> 300 // <!-- Miscellaneous Technical --> 301 initialMap.put("\u2308", "⌈"); // left ceiling = apl upstile,U+2308 ISOamsc --> 302 initialMap.put("\u2309", "⌉"); // right ceiling, U+2309 ISOamsc --> 303 initialMap.put("\u230A", "⌊"); // left floor = apl downstile,U+230A ISOamsc --> 304 initialMap.put("\u230B", "⌋"); // right floor, U+230B ISOamsc --> 305 initialMap.put("\u2329", "⟨"); // left-pointing angle bracket = bra,U+2329 ISOtech --> 306 // <!-- lang is NOT the same character as U+003C 'less than' or U+2039 'single left-pointing angle quotation 307 // mark' --> 308 initialMap.put("\u232A", "⟩"); // right-pointing angle bracket = ket,U+232A ISOtech --> 309 // <!-- rang is NOT the same character as U+003E 'greater than' or U+203A 310 // 'single right-pointing angle quotation mark' --> 311 // <!-- Geometric Shapes --> 312 initialMap.put("\u25CA", "◊"); // lozenge, U+25CA ISOpub --> 313 // <!-- Miscellaneous Symbols --> 314 initialMap.put("\u2660", "♠"); // black spade suit, U+2660 ISOpub --> 315 // <!-- black here seems to mean filled as opposed to hollow --> 316 initialMap.put("\u2663", "♣"); // black club suit = shamrock,U+2663 ISOpub --> 317 initialMap.put("\u2665", "♥"); // black heart suit = valentine,U+2665 ISOpub --> 318 initialMap.put("\u2666", "♦"); // black diamond suit, U+2666 ISOpub --> 319 320 // <!-- Latin Extended-A --> 321 initialMap.put("\u0152", "Œ"); // -- latin capital ligature OE,U+0152 ISOlat2 --> 322 initialMap.put("\u0153", "œ"); // -- latin small ligature oe, U+0153 ISOlat2 --> 323 // <!-- ligature is a misnomer, this is a separate character in some languages --> 324 initialMap.put("\u0160", "Š"); // -- latin capital letter S with caron,U+0160 ISOlat2 --> 325 initialMap.put("\u0161", "š"); // -- latin small letter s with caron,U+0161 ISOlat2 --> 326 initialMap.put("\u0178", "Ÿ"); // -- latin capital letter Y with dieresis,U+0178 ISOlat2 --> 327 // <!-- Spacing Modifier Letters --> 328 initialMap.put("\u02C6", "ˆ"); // -- modifier letter circumflex accent,U+02C6 ISOpub --> 329 initialMap.put("\u02DC", "˜"); // small tilde, U+02DC ISOdia --> 330 // <!-- General Punctuation --> 331 initialMap.put("\u2002", " "); // en space, U+2002 ISOpub --> 332 initialMap.put("\u2003", " "); // em space, U+2003 ISOpub --> 333 initialMap.put("\u2009", " "); // thin space, U+2009 ISOpub --> 334 initialMap.put("\u200C", "‌"); // zero width non-joiner,U+200C NEW RFC 2070 --> 335 initialMap.put("\u200D", "‍"); // zero width joiner, U+200D NEW RFC 2070 --> 336 initialMap.put("\u200E", "‎"); // left-to-right mark, U+200E NEW RFC 2070 --> 337 initialMap.put("\u200F", "‏"); // right-to-left mark, U+200F NEW RFC 2070 --> 338 initialMap.put("\u2013", "–"); // en dash, U+2013 ISOpub --> 339 initialMap.put("\u2014", "—"); // em dash, U+2014 ISOpub --> 340 initialMap.put("\u2018", "‘"); // left single quotation mark,U+2018 ISOnum --> 341 initialMap.put("\u2019", "’"); // right single quotation mark,U+2019 ISOnum --> 342 initialMap.put("\u201A", "‚"); // single low-9 quotation mark, U+201A NEW --> 343 initialMap.put("\u201C", "“"); // left double quotation mark,U+201C ISOnum --> 344 initialMap.put("\u201D", "”"); // right double quotation mark,U+201D ISOnum --> 345 initialMap.put("\u201E", "„"); // double low-9 quotation mark, U+201E NEW --> 346 initialMap.put("\u2020", "†"); // dagger, U+2020 ISOpub --> 347 initialMap.put("\u2021", "‡"); // double dagger, U+2021 ISOpub --> 348 initialMap.put("\u2030", "‰"); // per mille sign, U+2030 ISOtech --> 349 initialMap.put("\u2039", "‹"); // single left-pointing angle quotation mark,U+2039 ISO proposed --> 350 // <!-- lsaquo is proposed but not yet ISO standardized --> 351 initialMap.put("\u203A", "›"); // single right-pointing angle quotation mark,U+203A ISO proposed --> 352 // <!-- rsaquo is proposed but not yet ISO standardized --> 353 initialMap.put("\u20AC", "€"); // -- euro sign, U+20AC NEW --> 354 HTML40_EXTENDED_ESCAPE = Collections.unmodifiableMap(initialMap); 355 } 356 357 /** 358 * Reverse of {@link #HTML40_EXTENDED_ESCAPE} for unescaping purposes. 359 */ 360 public static final Map<CharSequence, CharSequence> HTML40_EXTENDED_UNESCAPE; 361 362 static { 363 HTML40_EXTENDED_UNESCAPE = Collections.unmodifiableMap(invert(HTML40_EXTENDED_ESCAPE)); 364 } 365 366 /** 367 * A Map<CharSequence, CharSequence> to escape the basic XML and HTML 368 * character entities. 369 * 370 * Namely: {@code " & < >} 371 */ 372 public static final Map<CharSequence, CharSequence> BASIC_ESCAPE; 373 374 static { 375 final Map<CharSequence, CharSequence> initialMap = new HashMap<>(); 376 initialMap.put("\"", """); // " - double-quote 377 initialMap.put("&", "&"); // & - ampersand 378 initialMap.put("<", "<"); // < - less-than 379 initialMap.put(">", ">"); // > - greater-than 380 BASIC_ESCAPE = Collections.unmodifiableMap(initialMap); 381 } 382 383 /** 384 * Reverse of {@link #BASIC_ESCAPE} for unescaping purposes. 385 */ 386 public static final Map<CharSequence, CharSequence> BASIC_UNESCAPE; 387 388 static { 389 BASIC_UNESCAPE = Collections.unmodifiableMap(invert(BASIC_ESCAPE)); 390 } 391 392 /** 393 * A Map<CharSequence, CharSequence> to escape the apostrophe character to 394 * its XML character entity. 395 */ 396 public static final Map<CharSequence, CharSequence> APOS_ESCAPE; 397 398 static { 399 final Map<CharSequence, CharSequence> initialMap = new HashMap<>(); 400 initialMap.put("'", "'"); // XML apostrophe 401 APOS_ESCAPE = Collections.unmodifiableMap(initialMap); 402 } 403 404 /** 405 * Reverse of {@link #APOS_ESCAPE} for unescaping purposes. 406 */ 407 public static final Map<CharSequence, CharSequence> APOS_UNESCAPE; 408 409 static { 410 APOS_UNESCAPE = Collections.unmodifiableMap(invert(APOS_ESCAPE)); 411 } 412 413 /** 414 * A Map<CharSequence, CharSequence> to escape the Java control characters. 415 * 416 * Namely: {@code \b \n \t \f \r} 417 */ 418 public static final Map<CharSequence, CharSequence> JAVA_CTRL_CHARS_ESCAPE; 419 420 static { 421 final Map<CharSequence, CharSequence> initialMap = new HashMap<>(); 422 initialMap.put("\b", "\\b"); 423 initialMap.put("\n", "\\n"); 424 initialMap.put("\t", "\\t"); 425 initialMap.put("\f", "\\f"); 426 initialMap.put("\r", "\\r"); 427 JAVA_CTRL_CHARS_ESCAPE = Collections.unmodifiableMap(initialMap); 428 } 429 430 /** 431 * Reverse of {@link #JAVA_CTRL_CHARS_ESCAPE} for unescaping purposes. 432 */ 433 public static final Map<CharSequence, CharSequence> JAVA_CTRL_CHARS_UNESCAPE; 434 435 static { 436 JAVA_CTRL_CHARS_UNESCAPE = Collections.unmodifiableMap(invert(JAVA_CTRL_CHARS_ESCAPE)); 437 } 438 439 /** 440 * Inverts an escape Map into an unescape Map. 441 * 442 * @param map Map<String, String> to be inverted 443 * @return Map<String, String> inverted array 444 */ 445 public static Map<CharSequence, CharSequence> invert(final Map<CharSequence, CharSequence> map) { 446 return map.entrySet().stream().collect(Collectors.toMap(Entry::getValue, Entry::getKey)); 447 } 448 449}