r25048: From the archives (patch found in one of my old working trees):
[jelmer/samba4-debian.git] / webapps / qooxdoo-0.6.5-sdk / frontend / framework / source / class / qx / html / Entity.js
1 /* ************************************************************************
2
3    qooxdoo - the new era of web development
4
5    http://qooxdoo.org
6
7    Copyright:
8      2004-2007 1&1 Internet AG, Germany, http://www.1and1.org
9
10    License:
11      LGPL: http://www.gnu.org/licenses/lgpl.html
12      EPL: http://www.eclipse.org/org/documents/epl-v10.php
13      See the LICENSE file in the project's top-level directory for details.
14
15    Authors:
16      * Fabian Jakobs (fjakobs)
17
18 ************************************************************************ */
19
20 /* ************************************************************************
21
22 #require(qx.lang.Object)
23
24 ************************************************************************ */
25
26 /**
27  * A Collection of utility functions to escape and unescape strings.
28  */
29 qx.OO.defineClass("qx.html.Entity");
30
31
32 /** Mapping of HTML entity names to the corresponding char code */
33 qx.Class.TO_CHARCODE = {
34   "quot": 34, // " - double-quote
35   "amp": 38, // &
36   "lt": 60, // <
37   "gt": 62, // >
38
39    // http://www.w3.org/TR/REC-html40/sgml/entities.html
40    // ISO 8859-1 characters
41   "nbsp": 160, // no-break space
42   "iexcl": 161, // inverted exclamation mark
43   "cent": 162, // cent sign
44   "pound": 163, // pound sterling sign
45   "curren": 164, // general currency sign
46   "yen": 165, // yen sign
47   "brvbar": 166, // broken (vertical) bar
48   "sect": 167, // section sign
49   "uml": 168, // umlaut (dieresis)
50   "copy": 169, // copyright sign
51   "ordf": 170, // ordinal indicator, feminine
52   "laquo": 171, // angle quotation mark, left
53   "not": 172, // not sign
54   "shy": 173, // soft hyphen
55   "reg": 174, // registered sign
56   "macr": 175, // macron
57   "deg": 176, // degree sign
58   "plusmn": 177, // plus-or-minus sign
59   "sup2": 178, // superscript two
60   "sup3": 179, // superscript three
61   "acute": 180, // acute accent
62   "micro": 181, // micro sign
63   "para": 182, // pilcrow (paragraph sign)
64   "middot": 183, // middle dot
65   "cedil": 184, // cedilla
66   "sup1": 185, // superscript one
67   "ordm": 186, // ordinal indicator, masculine
68   "raquo": 187, // angle quotation mark, right
69   "frac14": 188, // fraction one-quarter
70   "frac12": 189, // fraction one-half
71   "frac34": 190, // fraction three-quarters
72   "iquest": 191, // inverted question mark
73   "Agrave": 192, // capital A, grave accent
74   "Aacute": 193, // capital A, acute accent
75   "Acirc": 194, // capital A, circumflex accent
76   "Atilde": 195, // capital A, tilde
77   "Auml": 196, // capital A, dieresis or umlaut mark
78   "Aring": 197, // capital A, ring
79   "AElig": 198, // capital AE diphthong (ligature)
80   "Ccedil": 199, // capital C, cedilla
81   "Egrave": 200, // capital E, grave accent
82   "Eacute": 201, // capital E, acute accent
83   "Ecirc": 202, // capital E, circumflex accent
84   "Euml": 203, // capital E, dieresis or umlaut mark
85   "Igrave": 204, // capital I, grave accent
86   "Iacute": 205, // capital I, acute accent
87   "Icirc": 206, // capital I, circumflex accent
88   "Iuml": 207, // capital I, dieresis or umlaut mark
89   "ETH": 208, // capital Eth, Icelandic
90   "Ntilde": 209, // capital N, tilde
91   "Ograve": 210, // capital O, grave accent
92   "Oacute": 211, // capital O, acute accent
93   "Ocirc": 212, // capital O, circumflex accent
94   "Otilde": 213, // capital O, tilde
95   "Ouml": 214, // capital O, dieresis or umlaut mark
96   "times": 215, // multiply sign
97   "Oslash": 216, // capital O, slash
98   "Ugrave": 217, // capital U, grave accent
99   "Uacute": 218, // capital U, acute accent
100   "Ucirc": 219, // capital U, circumflex accent
101   "Uuml": 220, // capital U, dieresis or umlaut mark
102   "Yacute": 221, // capital Y, acute accent
103   "THORN": 222, // capital THORN, Icelandic
104   "szlig": 223, // small sharp s, German (sz ligature)
105   "agrave": 224, // small a, grave accent
106   "aacute": 225, // small a, acute accent
107   "acirc": 226, // small a, circumflex accent
108   "atilde": 227, // small a, tilde
109   "auml": 228, // small a, dieresis or umlaut mark
110   "aring": 229, // small a, ring
111   "aelig": 230, // small ae diphthong (ligature)
112   "ccedil": 231, // small c, cedilla
113   "egrave": 232, // small e, grave accent
114   "eacute": 233, // small e, acute accent
115   "ecirc": 234, // small e, circumflex accent
116   "euml": 235, // small e, dieresis or umlaut mark
117   "igrave": 236, // small i, grave accent
118   "iacute": 237, // small i, acute accent
119   "icirc": 238, // small i, circumflex accent
120   "iuml": 239, // small i, dieresis or umlaut mark
121   "eth": 240, // small eth, Icelandic
122   "ntilde": 241, // small n, tilde
123   "ograve": 242, // small o, grave accent
124   "oacute": 243, // small o, acute accent
125   "ocirc": 244, // small o, circumflex accent
126   "otilde": 245, // small o, tilde
127   "ouml": 246, // small o, dieresis or umlaut mark
128   "divide": 247, // divide sign
129   "oslash": 248, // small o, slash
130   "ugrave": 249, // small u, grave accent
131   "uacute": 250, // small u, acute accent
132   "ucirc": 251, // small u, circumflex accent
133   "uuml": 252, // small u, dieresis or umlaut mark
134   "yacute": 253, // small y, acute accent
135   "thorn": 254, // small thorn, Icelandic
136   "yuml": 255, // small y, dieresis or umlaut mark
137   // Latin Extended-B
138   "fnof": 402, //latin small f with hook = function= florin, U+0192 ISOtech
139   // Greek
140   "Alpha": 913, //greek capital letter alpha, U+0391
141   "Beta": 914, //greek capital letter beta, U+0392
142   "Gamma": 915, //greek capital letter gamma,U+0393 ISOgrk3
143   "Delta": 916, //greek capital letter delta,U+0394 ISOgrk3
144   "Epsilon": 917, //greek capital letter epsilon, U+0395
145   "Zeta": 918, //greek capital letter zeta, U+0396
146   "Eta": 919, //greek capital letter eta, U+0397
147   "Theta": 920, //greek capital letter theta,U+0398 ISOgrk3
148   "Iota": 921, //greek capital letter iota, U+0399
149   "Kappa": 922, //greek capital letter kappa, U+039A
150   "Lambda": 923, //greek capital letter lambda,U+039B ISOgrk3
151   "Mu": 924, //greek capital letter mu, U+039C
152   "Nu": 925, //greek capital letter nu, U+039D
153   "Xi": 926, //greek capital letter xi, U+039E ISOgrk3
154   "Omicron": 927, //greek capital letter omicron, U+039F
155   "Pi": 928, //greek capital letter pi, U+03A0 ISOgrk3
156   "Rho": 929, //greek capital letter rho, U+03A1
157   // there is no Sigmaf, and no U+03A2 character either
158   "Sigma": 931, //greek capital letter sigma,U+03A3 ISOgrk3
159   "Tau": 932, //greek capital letter tau, U+03A4
160   "Upsilon": 933, //greek capital letter upsilon,U+03A5 ISOgrk3
161   "Phi": 934, //greek capital letter phi,U+03A6 ISOgrk3
162   "Chi": 935, //greek capital letter chi, U+03A7
163   "Psi": 936, //greek capital letter psi,U+03A8 ISOgrk3
164   "Omega": 937, //greek capital letter omega,U+03A9 ISOgrk3
165   "alpha": 945, //greek small letter alpha,U+03B1 ISOgrk3
166   "beta": 946, //greek small letter beta, U+03B2 ISOgrk3
167   "gamma": 947, //greek small letter gamma,U+03B3 ISOgrk3
168   "delta": 948, //greek small letter delta,U+03B4 ISOgrk3
169   "epsilon": 949, //greek small letter epsilon,U+03B5 ISOgrk3
170   "zeta": 950, //greek small letter zeta, U+03B6 ISOgrk3
171   "eta": 951, //greek small letter eta, U+03B7 ISOgrk3
172   "theta": 952, //greek small letter theta,U+03B8 ISOgrk3
173   "iota": 953, //greek small letter iota, U+03B9 ISOgrk3
174   "kappa": 954, //greek small letter kappa,U+03BA ISOgrk3
175   "lambda": 955, //greek small letter lambda,U+03BB ISOgrk3
176   "mu": 956, //greek small letter mu, U+03BC ISOgrk3
177   "nu": 957, //greek small letter nu, U+03BD ISOgrk3
178   "xi": 958, //greek small letter xi, U+03BE ISOgrk3
179   "omicron": 959, //greek small letter omicron, U+03BF NEW
180   "pi": 960, //greek small letter pi, U+03C0 ISOgrk3
181   "rho": 961, //greek small letter rho, U+03C1 ISOgrk3
182   "sigmaf": 962, //greek small letter final sigma,U+03C2 ISOgrk3
183   "sigma": 963, //greek small letter sigma,U+03C3 ISOgrk3
184   "tau": 964, //greek small letter tau, U+03C4 ISOgrk3
185   "upsilon": 965, //greek small letter upsilon,U+03C5 ISOgrk3
186   "phi": 966, //greek small letter phi, U+03C6 ISOgrk3
187   "chi": 967, //greek small letter chi, U+03C7 ISOgrk3
188   "psi": 968, //greek small letter psi, U+03C8 ISOgrk3
189   "omega": 969, //greek small letter omega,U+03C9 ISOgrk3
190   "thetasym": 977, //greek small letter theta symbol,U+03D1 NEW
191   "upsih": 978, //greek upsilon with hook symbol,U+03D2 NEW
192   "piv": 982, //greek pi symbol, U+03D6 ISOgrk3
193   // General Punctuation
194   "bull": 8226, //bullet = black small circle,U+2022 ISOpub
195   // bullet is NOT the same as bullet operator, U+2219
196   "hellip": 8230, //horizontal ellipsis = three dot leader,U+2026 ISOpub
197   "prime": 8242, //prime = minutes = feet, U+2032 ISOtech
198   "Prime": 8243, //double prime = seconds = inches,U+2033 ISOtech
199   "oline": 8254, //overline = spacing overscore,U+203E NEW
200   "frasl": 8260, //fraction slash, U+2044 NEW
201   // Letterlike Symbols
202   "weierp": 8472, //script capital P = power set= Weierstrass p, U+2118 ISOamso
203   "image": 8465, //blackletter capital I = imaginary part,U+2111 ISOamso
204   "real": 8476, //blackletter capital R = real part symbol,U+211C ISOamso
205   "trade": 8482, //trade mark sign, U+2122 ISOnum
206   "alefsym": 8501, //alef symbol = first transfinite cardinal,U+2135 NEW
207   // alef symbol is NOT the same as hebrew letter alef,U+05D0 although the same glyph could be used to depict both characters
208   // Arrows
209   "larr": 8592, //leftwards arrow, U+2190 ISOnum
210   "uarr": 8593, //upwards arrow, U+2191 ISOnum-->
211   "rarr": 8594, //rightwards arrow, U+2192 ISOnum
212   "darr": 8595, //downwards arrow, U+2193 ISOnum
213   "harr": 8596, //left right arrow, U+2194 ISOamsa
214   "crarr": 8629, //downwards arrow with corner leftwards= carriage return, U+21B5 NEW
215   "lArr": 8656, //leftwards double arrow, U+21D0 ISOtech
216   // ISO 10646 does not say that lArr is the same as the 'is implied by' arrowbut also does not have any other character for that function. So ? lArr canbe used for 'is implied by' as ISOtech suggests
217   "uArr": 8657, //upwards double arrow, U+21D1 ISOamsa
218   "rArr": 8658, //rightwards double arrow,U+21D2 ISOtech
219   // ISO 10646 does not say this is the 'implies' character but does not have another character with this function so ?rArr can be used for 'implies' as ISOtech suggests
220   "dArr": 8659, //downwards double arrow, U+21D3 ISOamsa
221   "hArr": 8660, //left right double arrow,U+21D4 ISOamsa
222   // Mathematical Operators
223   "forall": 8704, //for all, U+2200 ISOtech
224   "part": 8706, //partial differential, U+2202 ISOtech
225   "exist": 8707, //there exists, U+2203 ISOtech
226   "empty": 8709, //empty set = null set = diameter,U+2205 ISOamso
227   "nabla": 8711, //nabla = backward difference,U+2207 ISOtech
228   "isin": 8712, //element of, U+2208 ISOtech
229   "notin": 8713, //not an element of, U+2209 ISOtech
230   "ni": 8715, //contains as member, U+220B ISOtech
231   // should there be a more memorable name than 'ni'?
232   "prod": 8719, //n-ary product = product sign,U+220F ISOamsb
233   // prod is NOT the same character as U+03A0 'greek capital letter pi' though the same glyph might be used for both
234   "sum": 8721, //n-ary summation, U+2211 ISOamsb
235   // sum is NOT the same character as U+03A3 'greek capital letter sigma' though the same glyph might be used for both
236   "minus": 8722, //minus sign, U+2212 ISOtech
237   "lowast": 8727, //asterisk operator, U+2217 ISOtech
238   "radic": 8730, //square root = radical sign,U+221A ISOtech
239   "prop": 8733, //proportional to, U+221D ISOtech
240   "infin": 8734, //infinity, U+221E ISOtech
241   "ang": 8736, //angle, U+2220 ISOamso
242   "and": 8743, //logical and = wedge, U+2227 ISOtech
243   "or": 8744, //logical or = vee, U+2228 ISOtech
244   "cap": 8745, //intersection = cap, U+2229 ISOtech
245   "cup": 8746, //union = cup, U+222A ISOtech
246   "int": 8747, //integral, U+222B ISOtech
247   "there4": 8756, //therefore, U+2234 ISOtech
248   "sim": 8764, //tilde operator = varies with = similar to,U+223C ISOtech
249   // tilde operator is NOT the same character as the tilde, U+007E,although the same glyph might be used to represent both
250   "cong": 8773, //approximately equal to, U+2245 ISOtech
251   "asymp": 8776, //almost equal to = asymptotic to,U+2248 ISOamsr
252   "ne": 8800, //not equal to, U+2260 ISOtech
253   "equiv": 8801, //identical to, U+2261 ISOtech
254   "le": 8804, //less-than or equal to, U+2264 ISOtech
255   "ge": 8805, //greater-than or equal to,U+2265 ISOtech
256   "sub": 8834, //subset of, U+2282 ISOtech
257   "sup": 8835, //superset of, U+2283 ISOtech
258   // note that nsup, 'not a superset of, U+2283' is not covered by the Symbol font encoding and is not included. Should it be, for symmetry?It is in ISOamsn  --> <!ENTITY nsub": 8836,  //not a subset of, U+2284 ISOamsn
259   "sube": 8838, //subset of or equal to, U+2286 ISOtech
260   "supe": 8839, //superset of or equal to,U+2287 ISOtech
261   "oplus": 8853, //circled plus = direct sum,U+2295 ISOamsb
262   "otimes": 8855, //circled times = vector product,U+2297 ISOamsb
263   "perp": 8869, //up tack = orthogonal to = perpendicular,U+22A5 ISOtech
264   "sdot": 8901, //dot operator, U+22C5 ISOamsb
265   // dot operator is NOT the same character as U+00B7 middle dot
266   // Miscellaneous Technical
267   "lceil": 8968, //left ceiling = apl upstile,U+2308 ISOamsc
268   "rceil": 8969, //right ceiling, U+2309 ISOamsc
269   "lfloor": 8970, //left floor = apl downstile,U+230A ISOamsc
270   "rfloor": 8971, //right floor, U+230B ISOamsc
271   "lang": 9001, //left-pointing angle bracket = bra,U+2329 ISOtech
272   // lang is NOT the same character as U+003C 'less than' or U+2039 'single left-pointing angle quotation mark'
273   "rang": 9002, //right-pointing angle bracket = ket,U+232A ISOtech
274   // rang is NOT the same character as U+003E 'greater than' or U+203A 'single right-pointing angle quotation mark'
275   // Geometric Shapes
276   "loz": 9674, //lozenge, U+25CA ISOpub
277   // Miscellaneous Symbols
278   "spades": 9824, //black spade suit, U+2660 ISOpub
279   // black here seems to mean filled as opposed to hollow
280   "clubs": 9827, //black club suit = shamrock,U+2663 ISOpub
281   "hearts": 9829, //black heart suit = valentine,U+2665 ISOpub
282   "diams": 9830, //black diamond suit, U+2666 ISOpub
283
284   // Latin Extended-A
285   "OElig": 338, //  -- latin capital ligature OE,U+0152 ISOlat2
286   "oelig": 339, //  -- latin small ligature oe, U+0153 ISOlat2
287   // ligature is a misnomer, this is a separate character in some languages
288   "Scaron": 352, //  -- latin capital letter S with caron,U+0160 ISOlat2
289   "scaron": 353, //  -- latin small letter s with caron,U+0161 ISOlat2
290   "Yuml": 376, //  -- latin capital letter Y with diaeresis,U+0178 ISOlat2
291   // Spacing Modifier Letters
292   "circ": 710, //  -- modifier letter circumflex accent,U+02C6 ISOpub
293   "tilde": 732, //small tilde, U+02DC ISOdia
294   // General Punctuation
295   "ensp": 8194, //en space, U+2002 ISOpub
296   "emsp": 8195, //em space, U+2003 ISOpub
297   "thinsp": 8201, //thin space, U+2009 ISOpub
298   "zwnj": 8204, //zero width non-joiner,U+200C NEW RFC 2070
299   "zwj": 8205, //zero width joiner, U+200D NEW RFC 2070
300   "lrm": 8206, //left-to-right mark, U+200E NEW RFC 2070
301   "rlm": 8207, //right-to-left mark, U+200F NEW RFC 2070
302   "ndash": 8211, //en dash, U+2013 ISOpub
303   "mdash": 8212, //em dash, U+2014 ISOpub
304   "lsquo": 8216, //left single quotation mark,U+2018 ISOnum
305   "rsquo": 8217, //right single quotation mark,U+2019 ISOnum
306   "sbquo": 8218, //single low-9 quotation mark, U+201A NEW
307   "ldquo": 8220, //left double quotation mark,U+201C ISOnum
308   "rdquo": 8221, //right double quotation mark,U+201D ISOnum
309   "bdquo": 8222, //double low-9 quotation mark, U+201E NEW
310   "dagger": 8224, //dagger, U+2020 ISOpub
311   "Dagger": 8225, //double dagger, U+2021 ISOpub
312   "permil": 8240, //per mille sign, U+2030 ISOtech
313   "lsaquo": 8249, //single left-pointing angle quotation mark,U+2039 ISO proposed
314   // lsaquo is proposed but not yet ISO standardized
315   "rsaquo": 8250, //single right-pointing angle quotation mark,U+203A ISO proposed
316   // rsaquo is proposed but not yet ISO standardized
317   "euro": 8364 //  -- euro sign, U+20AC NEW
318 };
319
320
321 /** Mapping of char codes to HTML entity names */
322 qx.Class.FROM_CHARCODE = qx.lang.Object.invert(qx.Class.TO_CHARCODE);
323