PageRenderTime 47ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/System.Web/Util/HttpEncoder.cs

https://bitbucket.org/cosi2/dotnetanywhere-wb
C# | 887 lines | 817 code | 61 blank | 9 comment | 144 complexity | 660baeeeed116c46f40d5ebbc2f9639c MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.IO;
  5. using System.Text;
  6. using System.Globalization;
  7. #if NET_4_0
  8. using System.Web.Configuration;
  9. #endif
  10. namespace System.Web.Util
  11. {
  12. #if NET_4_0
  13. public
  14. #endif
  15. class HttpEncoder
  16. {
  17. static char[] hexChars = "0123456789abcdef".ToCharArray();
  18. static object entitiesLock = new object();
  19. static SortedDictionary<string, char> entities;
  20. #if NET_4_0
  21. static Lazy <HttpEncoder> defaultEncoder;
  22. static Lazy <HttpEncoder> currentEncoderLazy;
  23. #else
  24. static HttpEncoder defaultEncoder;
  25. #endif
  26. static HttpEncoder currentEncoder;
  27. static IDictionary<string, char> Entities
  28. {
  29. get
  30. {
  31. lock (entitiesLock)
  32. {
  33. if (entities == null)
  34. InitEntities();
  35. return entities;
  36. }
  37. }
  38. }
  39. public static HttpEncoder Current
  40. {
  41. get
  42. {
  43. #if NET_4_0
  44. if (currentEncoder == null)
  45. currentEncoder = currentEncoderLazy.Value;
  46. #endif
  47. return currentEncoder;
  48. }
  49. #if NET_4_0
  50. set {
  51. if (value == null)
  52. throw new ArgumentNullException ("value");
  53. currentEncoder = value;
  54. }
  55. #endif
  56. }
  57. public static HttpEncoder Default
  58. {
  59. get
  60. {
  61. #if NET_4_0
  62. return defaultEncoder.Value;
  63. #else
  64. return defaultEncoder;
  65. #endif
  66. }
  67. }
  68. static HttpEncoder()
  69. {
  70. #if NET_4_0
  71. defaultEncoder = new Lazy <HttpEncoder> (() => new HttpEncoder ());
  72. currentEncoderLazy = new Lazy <HttpEncoder> (new Func <HttpEncoder> (GetCustomEncoderFromConfig));
  73. #else
  74. defaultEncoder = new HttpEncoder();
  75. currentEncoder = defaultEncoder;
  76. #endif
  77. }
  78. public HttpEncoder()
  79. {
  80. }
  81. #if NET_4_0
  82. protected internal virtual
  83. #else
  84. internal static
  85. #endif
  86. void HeaderNameValueEncode(string headerName, string headerValue, out string encodedHeaderName, out string encodedHeaderValue)
  87. {
  88. if (String.IsNullOrEmpty(headerName))
  89. encodedHeaderName = headerName;
  90. else
  91. encodedHeaderName = EncodeHeaderString(headerName);
  92. if (String.IsNullOrEmpty(headerValue))
  93. encodedHeaderValue = headerValue;
  94. else
  95. encodedHeaderValue = EncodeHeaderString(headerValue);
  96. }
  97. static void StringBuilderAppend(string s, ref StringBuilder sb)
  98. {
  99. if (sb == null)
  100. sb = new StringBuilder(s);
  101. else
  102. sb.Append(s);
  103. }
  104. static string EncodeHeaderString(string input)
  105. {
  106. StringBuilder sb = null;
  107. char ch;
  108. for (int i = 0; i < input.Length; i++)
  109. {
  110. ch = input[i];
  111. if ((ch < 32 && ch != 9) || ch == 127)
  112. StringBuilderAppend(String.Format("%{0:x2}", (int)ch), ref sb);
  113. }
  114. if (sb != null)
  115. return sb.ToString();
  116. return input;
  117. }
  118. #if NET_4_0
  119. protected internal virtual void HtmlAttributeEncode (string value, TextWriter output)
  120. {
  121. if (output == null)
  122. throw new ArgumentNullException ("output");
  123. if (String.IsNullOrEmpty (value))
  124. return;
  125. output.Write (HtmlAttributeEncode (value));
  126. }
  127. protected internal virtual void HtmlDecode (string value, TextWriter output)
  128. {
  129. if (output == null)
  130. throw new ArgumentNullException ("output");
  131. output.Write (HtmlDecode (value));
  132. }
  133. protected internal virtual void HtmlEncode (string value, TextWriter output)
  134. {
  135. if (output == null)
  136. throw new ArgumentNullException ("output");
  137. output.Write (HtmlEncode (value));
  138. }
  139. protected internal virtual byte[] UrlEncode (byte[] bytes, int offset, int count)
  140. {
  141. return UrlEncodeToBytes (bytes, offset, count);
  142. }
  143. static HttpEncoder GetCustomEncoderFromConfig ()
  144. {
  145. var cfg = HttpRuntime.Section;
  146. string typeName = cfg.EncoderType;
  147. if (String.Compare (typeName, "System.Web.Util.HttpEncoder", StringComparison.OrdinalIgnoreCase) == 0)
  148. return Default;
  149. Type t = Type.GetType (typeName, false);
  150. if (t == null)
  151. throw new ConfigurationErrorsException (String.Format ("Could not load type '{0}'.", typeName));
  152. if (!typeof (HttpEncoder).IsAssignableFrom (t))
  153. throw new ConfigurationErrorsException (
  154. String.Format ("'{0}' is not allowed here because it does not extend class 'System.Web.Util.HttpEncoder'.", typeName)
  155. );
  156. return Activator.CreateInstance (t, false) as HttpEncoder;
  157. }
  158. #endif
  159. #if NET_4_0
  160. protected internal virtual
  161. #else
  162. internal static
  163. #endif
  164. string UrlPathEncode(string value)
  165. {
  166. if (String.IsNullOrEmpty(value))
  167. return value;
  168. MemoryStream result = new MemoryStream();
  169. int length = value.Length;
  170. for (int i = 0; i < length; i++)
  171. UrlPathEncodeChar(value[i], result);
  172. return Encoding.ASCII.GetString(result.ToArray());
  173. }
  174. internal static byte[] UrlEncodeToBytes(byte[] bytes, int offset, int count)
  175. {
  176. if (bytes == null)
  177. throw new ArgumentNullException("bytes");
  178. int blen = bytes.Length;
  179. if (blen == 0)
  180. return new byte[0];
  181. if (offset < 0 || offset >= blen)
  182. throw new ArgumentOutOfRangeException("offset");
  183. if (count < 0 || count > blen - offset)
  184. throw new ArgumentOutOfRangeException("count");
  185. MemoryStream result = new MemoryStream(count);
  186. int end = offset + count;
  187. for (int i = offset; i < end; i++)
  188. UrlEncodeChar((char)bytes[i], result, false);
  189. return result.ToArray();
  190. }
  191. internal static string HtmlEncode(string s)
  192. {
  193. if (s == null)
  194. return null;
  195. if (s.Length == 0)
  196. return String.Empty;
  197. bool needEncode = false;
  198. for (int i = 0; i < s.Length; i++)
  199. {
  200. char c = s[i];
  201. if (c == '&' || c == '"' || c == '<' || c == '>' || c > 159
  202. #if NET_4_0
  203. || c == '\''
  204. #endif
  205. )
  206. {
  207. needEncode = true;
  208. break;
  209. }
  210. }
  211. if (!needEncode)
  212. return s;
  213. StringBuilder output = new StringBuilder();
  214. char ch;
  215. int len = s.Length;
  216. for (int i = 0; i < len; i++)
  217. {
  218. switch (s[i])
  219. {
  220. case '&':
  221. output.Append("&amp;");
  222. break;
  223. case '>':
  224. output.Append("&gt;");
  225. break;
  226. case '<':
  227. output.Append("&lt;");
  228. break;
  229. case '"':
  230. output.Append("&quot;");
  231. break;
  232. #if NET_4_0
  233. case '\'':
  234. output.Append ("&#39;");
  235. break;
  236. #endif
  237. case '\uff1c':
  238. output.Append("&#65308;");
  239. break;
  240. case '\uff1e':
  241. output.Append("&#65310;");
  242. break;
  243. default:
  244. ch = s[i];
  245. if (ch > 159 && ch < 256)
  246. {
  247. output.Append("&#");
  248. output.Append(((int)ch).ToString(CultureInfo.InvariantCulture));
  249. output.Append(";");
  250. }
  251. else
  252. output.Append(ch);
  253. break;
  254. }
  255. }
  256. return output.ToString();
  257. }
  258. internal static string HtmlAttributeEncode(string s)
  259. {
  260. #if NET_4_0
  261. if (String.IsNullOrEmpty (s))
  262. return String.Empty;
  263. #else
  264. if (s == null)
  265. return null;
  266. if (s.Length == 0)
  267. return String.Empty;
  268. #endif
  269. bool needEncode = false;
  270. for (int i = 0; i < s.Length; i++)
  271. {
  272. char c = s[i];
  273. if (c == '&' || c == '"' || c == '<'
  274. #if NET_4_0
  275. || c == '\''
  276. #endif
  277. )
  278. {
  279. needEncode = true;
  280. break;
  281. }
  282. }
  283. if (!needEncode)
  284. return s;
  285. StringBuilder output = new StringBuilder();
  286. int len = s.Length;
  287. for (int i = 0; i < len; i++)
  288. switch (s[i])
  289. {
  290. case '&':
  291. output.Append("&amp;");
  292. break;
  293. case '"':
  294. output.Append("&quot;");
  295. break;
  296. case '<':
  297. output.Append("&lt;");
  298. break;
  299. #if NET_4_0
  300. case '\'':
  301. output.Append ("&#39;");
  302. break;
  303. #endif
  304. default:
  305. output.Append(s[i]);
  306. break;
  307. }
  308. return output.ToString();
  309. }
  310. internal static string HtmlDecode(string s)
  311. {
  312. if (s == null)
  313. return null;
  314. if (s.Length == 0)
  315. return String.Empty;
  316. if (s.IndexOf('&') == -1)
  317. return s;
  318. #if NET_4_0
  319. StringBuilder rawEntity = new StringBuilder ();
  320. #endif
  321. StringBuilder entity = new StringBuilder();
  322. StringBuilder output = new StringBuilder();
  323. int len = s.Length;
  324. // 0 -> nothing,
  325. // 1 -> right after '&'
  326. // 2 -> between '&' and ';' but no '#'
  327. // 3 -> '#' found after '&' and getting numbers
  328. int state = 0;
  329. int number = 0;
  330. bool is_hex_value = false;
  331. bool have_trailing_digits = false;
  332. for (int i = 0; i < len; i++)
  333. {
  334. char c = s[i];
  335. if (state == 0)
  336. {
  337. if (c == '&')
  338. {
  339. entity.Append(c);
  340. #if NET_4_0
  341. rawEntity.Append (c);
  342. #endif
  343. state = 1;
  344. }
  345. else
  346. {
  347. output.Append(c);
  348. }
  349. continue;
  350. }
  351. if (c == '&')
  352. {
  353. state = 1;
  354. if (have_trailing_digits)
  355. {
  356. entity.Append(number.ToString(CultureInfo.InvariantCulture));
  357. have_trailing_digits = false;
  358. }
  359. output.Append(entity.ToString());
  360. entity.Length = 0;
  361. entity.Append('&');
  362. continue;
  363. }
  364. if (state == 1)
  365. {
  366. if (c == ';')
  367. {
  368. state = 0;
  369. output.Append(entity.ToString());
  370. output.Append(c);
  371. entity.Length = 0;
  372. }
  373. else
  374. {
  375. number = 0;
  376. is_hex_value = false;
  377. if (c != '#')
  378. {
  379. state = 2;
  380. }
  381. else
  382. {
  383. state = 3;
  384. }
  385. entity.Append(c);
  386. #if NET_4_0
  387. rawEntity.Append (c);
  388. #endif
  389. }
  390. }
  391. else if (state == 2)
  392. {
  393. entity.Append(c);
  394. if (c == ';')
  395. {
  396. string key = entity.ToString();
  397. if (key.Length > 1 && Entities.ContainsKey(key.Substring(1, key.Length - 2)))
  398. key = Entities[key.Substring(1, key.Length - 2)].ToString();
  399. output.Append(key);
  400. state = 0;
  401. entity.Length = 0;
  402. #if NET_4_0
  403. rawEntity.Length = 0;
  404. #endif
  405. }
  406. }
  407. else if (state == 3)
  408. {
  409. if (c == ';')
  410. {
  411. #if NET_4_0
  412. if (number == 0)
  413. output.Append (rawEntity.ToString () + ";");
  414. else
  415. #endif
  416. if (number > 65535)
  417. {
  418. output.Append("&#");
  419. output.Append(number.ToString(CultureInfo.InvariantCulture));
  420. output.Append(";");
  421. }
  422. else
  423. {
  424. output.Append((char)number);
  425. }
  426. state = 0;
  427. entity.Length = 0;
  428. #if NET_4_0
  429. rawEntity.Length = 0;
  430. #endif
  431. have_trailing_digits = false;
  432. }
  433. else if (is_hex_value && Uri.IsHexDigit(c))
  434. {
  435. number = number * 16 + Uri.FromHex(c);
  436. have_trailing_digits = true;
  437. #if NET_4_0
  438. rawEntity.Append (c);
  439. #endif
  440. }
  441. else if (Char.IsDigit(c))
  442. {
  443. number = number * 10 + ((int)c - '0');
  444. have_trailing_digits = true;
  445. #if NET_4_0
  446. rawEntity.Append (c);
  447. #endif
  448. }
  449. else if (number == 0 && (c == 'x' || c == 'X'))
  450. {
  451. is_hex_value = true;
  452. #if NET_4_0
  453. rawEntity.Append (c);
  454. #endif
  455. }
  456. else
  457. {
  458. state = 2;
  459. if (have_trailing_digits)
  460. {
  461. entity.Append(number.ToString(CultureInfo.InvariantCulture));
  462. have_trailing_digits = false;
  463. }
  464. entity.Append(c);
  465. }
  466. }
  467. }
  468. if (entity.Length > 0)
  469. {
  470. output.Append(entity.ToString());
  471. }
  472. else if (have_trailing_digits)
  473. {
  474. output.Append(number.ToString(CultureInfo.InvariantCulture));
  475. }
  476. return output.ToString();
  477. }
  478. internal static bool NotEncoded(char c)
  479. {
  480. return (c == '!' || c == '(' || c == ')' || c == '*' || c == '-' || c == '.' || c == '_'
  481. #if !NET_4_0
  482. || c == '\''
  483. #endif
  484. );
  485. }
  486. internal static void UrlEncodeChar(char c, Stream result, bool isUnicode)
  487. {
  488. if (c > 255)
  489. {
  490. //FIXME: what happens when there is an internal error?
  491. //if (!isUnicode)
  492. // throw new ArgumentOutOfRangeException ("c", c, "c must be less than 256");
  493. int idx;
  494. int i = (int)c;
  495. result.WriteByte((byte)'%');
  496. result.WriteByte((byte)'u');
  497. idx = i >> 12;
  498. result.WriteByte((byte)hexChars[idx]);
  499. idx = (i >> 8) & 0x0F;
  500. result.WriteByte((byte)hexChars[idx]);
  501. idx = (i >> 4) & 0x0F;
  502. result.WriteByte((byte)hexChars[idx]);
  503. idx = i & 0x0F;
  504. result.WriteByte((byte)hexChars[idx]);
  505. return;
  506. }
  507. if (c > ' ' && NotEncoded(c))
  508. {
  509. result.WriteByte((byte)c);
  510. return;
  511. }
  512. if (c == ' ')
  513. {
  514. result.WriteByte((byte)'+');
  515. return;
  516. }
  517. if ((c < '0') ||
  518. (c < 'A' && c > '9') ||
  519. (c > 'Z' && c < 'a') ||
  520. (c > 'z'))
  521. {
  522. if (isUnicode && c > 127)
  523. {
  524. result.WriteByte((byte)'%');
  525. result.WriteByte((byte)'u');
  526. result.WriteByte((byte)'0');
  527. result.WriteByte((byte)'0');
  528. }
  529. else
  530. result.WriteByte((byte)'%');
  531. int idx = ((int)c) >> 4;
  532. result.WriteByte((byte)hexChars[idx]);
  533. idx = ((int)c) & 0x0F;
  534. result.WriteByte((byte)hexChars[idx]);
  535. }
  536. else
  537. result.WriteByte((byte)c);
  538. }
  539. internal static void UrlPathEncodeChar(char c, Stream result)
  540. {
  541. if (c < 33 || c > 126)
  542. {
  543. byte[] bIn = Encoding.UTF8.GetBytes(c.ToString());
  544. for (int i = 0; i < bIn.Length; i++)
  545. {
  546. result.WriteByte((byte)'%');
  547. int idx = ((int)bIn[i]) >> 4;
  548. result.WriteByte((byte)hexChars[idx]);
  549. idx = ((int)bIn[i]) & 0x0F;
  550. result.WriteByte((byte)hexChars[idx]);
  551. }
  552. }
  553. else if (c == ' ')
  554. {
  555. result.WriteByte((byte)'%');
  556. result.WriteByte((byte)'2');
  557. result.WriteByte((byte)'0');
  558. }
  559. else
  560. result.WriteByte((byte)c);
  561. }
  562. static void InitEntities()
  563. {
  564. // Build the hash table of HTML entity references. This list comes
  565. // from the HTML 4.01 W3C recommendation.
  566. entities = new SortedDictionary<string, char>(StringComparer.Ordinal);
  567. entities.Add("nbsp", '\u00A0');
  568. entities.Add("iexcl", '\u00A1');
  569. entities.Add("cent", '\u00A2');
  570. entities.Add("pound", '\u00A3');
  571. entities.Add("curren", '\u00A4');
  572. entities.Add("yen", '\u00A5');
  573. entities.Add("brvbar", '\u00A6');
  574. entities.Add("sect", '\u00A7');
  575. entities.Add("uml", '\u00A8');
  576. entities.Add("copy", '\u00A9');
  577. entities.Add("ordf", '\u00AA');
  578. entities.Add("laquo", '\u00AB');
  579. entities.Add("not", '\u00AC');
  580. entities.Add("shy", '\u00AD');
  581. entities.Add("reg", '\u00AE');
  582. entities.Add("macr", '\u00AF');
  583. entities.Add("deg", '\u00B0');
  584. entities.Add("plusmn", '\u00B1');
  585. entities.Add("sup2", '\u00B2');
  586. entities.Add("sup3", '\u00B3');
  587. entities.Add("acute", '\u00B4');
  588. entities.Add("micro", '\u00B5');
  589. entities.Add("para", '\u00B6');
  590. entities.Add("middot", '\u00B7');
  591. entities.Add("cedil", '\u00B8');
  592. entities.Add("sup1", '\u00B9');
  593. entities.Add("ordm", '\u00BA');
  594. entities.Add("raquo", '\u00BB');
  595. entities.Add("frac14", '\u00BC');
  596. entities.Add("frac12", '\u00BD');
  597. entities.Add("frac34", '\u00BE');
  598. entities.Add("iquest", '\u00BF');
  599. entities.Add("Agrave", '\u00C0');
  600. entities.Add("Aacute", '\u00C1');
  601. entities.Add("Acirc", '\u00C2');
  602. entities.Add("Atilde", '\u00C3');
  603. entities.Add("Auml", '\u00C4');
  604. entities.Add("Aring", '\u00C5');
  605. entities.Add("AElig", '\u00C6');
  606. entities.Add("Ccedil", '\u00C7');
  607. entities.Add("Egrave", '\u00C8');
  608. entities.Add("Eacute", '\u00C9');
  609. entities.Add("Ecirc", '\u00CA');
  610. entities.Add("Euml", '\u00CB');
  611. entities.Add("Igrave", '\u00CC');
  612. entities.Add("Iacute", '\u00CD');
  613. entities.Add("Icirc", '\u00CE');
  614. entities.Add("Iuml", '\u00CF');
  615. entities.Add("ETH", '\u00D0');
  616. entities.Add("Ntilde", '\u00D1');
  617. entities.Add("Ograve", '\u00D2');
  618. entities.Add("Oacute", '\u00D3');
  619. entities.Add("Ocirc", '\u00D4');
  620. entities.Add("Otilde", '\u00D5');
  621. entities.Add("Ouml", '\u00D6');
  622. entities.Add("times", '\u00D7');
  623. entities.Add("Oslash", '\u00D8');
  624. entities.Add("Ugrave", '\u00D9');
  625. entities.Add("Uacute", '\u00DA');
  626. entities.Add("Ucirc", '\u00DB');
  627. entities.Add("Uuml", '\u00DC');
  628. entities.Add("Yacute", '\u00DD');
  629. entities.Add("THORN", '\u00DE');
  630. entities.Add("szlig", '\u00DF');
  631. entities.Add("agrave", '\u00E0');
  632. entities.Add("aacute", '\u00E1');
  633. entities.Add("acirc", '\u00E2');
  634. entities.Add("atilde", '\u00E3');
  635. entities.Add("auml", '\u00E4');
  636. entities.Add("aring", '\u00E5');
  637. entities.Add("aelig", '\u00E6');
  638. entities.Add("ccedil", '\u00E7');
  639. entities.Add("egrave", '\u00E8');
  640. entities.Add("eacute", '\u00E9');
  641. entities.Add("ecirc", '\u00EA');
  642. entities.Add("euml", '\u00EB');
  643. entities.Add("igrave", '\u00EC');
  644. entities.Add("iacute", '\u00ED');
  645. entities.Add("icirc", '\u00EE');
  646. entities.Add("iuml", '\u00EF');
  647. entities.Add("eth", '\u00F0');
  648. entities.Add("ntilde", '\u00F1');
  649. entities.Add("ograve", '\u00F2');
  650. entities.Add("oacute", '\u00F3');
  651. entities.Add("ocirc", '\u00F4');
  652. entities.Add("otilde", '\u00F5');
  653. entities.Add("ouml", '\u00F6');
  654. entities.Add("divide", '\u00F7');
  655. entities.Add("oslash", '\u00F8');
  656. entities.Add("ugrave", '\u00F9');
  657. entities.Add("uacute", '\u00FA');
  658. entities.Add("ucirc", '\u00FB');
  659. entities.Add("uuml", '\u00FC');
  660. entities.Add("yacute", '\u00FD');
  661. entities.Add("thorn", '\u00FE');
  662. entities.Add("yuml", '\u00FF');
  663. entities.Add("fnof", '\u0192');
  664. entities.Add("Alpha", '\u0391');
  665. entities.Add("Beta", '\u0392');
  666. entities.Add("Gamma", '\u0393');
  667. entities.Add("Delta", '\u0394');
  668. entities.Add("Epsilon", '\u0395');
  669. entities.Add("Zeta", '\u0396');
  670. entities.Add("Eta", '\u0397');
  671. entities.Add("Theta", '\u0398');
  672. entities.Add("Iota", '\u0399');
  673. entities.Add("Kappa", '\u039A');
  674. entities.Add("Lambda", '\u039B');
  675. entities.Add("Mu", '\u039C');
  676. entities.Add("Nu", '\u039D');
  677. entities.Add("Xi", '\u039E');
  678. entities.Add("Omicron", '\u039F');
  679. entities.Add("Pi", '\u03A0');
  680. entities.Add("Rho", '\u03A1');
  681. entities.Add("Sigma", '\u03A3');
  682. entities.Add("Tau", '\u03A4');
  683. entities.Add("Upsilon", '\u03A5');
  684. entities.Add("Phi", '\u03A6');
  685. entities.Add("Chi", '\u03A7');
  686. entities.Add("Psi", '\u03A8');
  687. entities.Add("Omega", '\u03A9');
  688. entities.Add("alpha", '\u03B1');
  689. entities.Add("beta", '\u03B2');
  690. entities.Add("gamma", '\u03B3');
  691. entities.Add("delta", '\u03B4');
  692. entities.Add("epsilon", '\u03B5');
  693. entities.Add("zeta", '\u03B6');
  694. entities.Add("eta", '\u03B7');
  695. entities.Add("theta", '\u03B8');
  696. entities.Add("iota", '\u03B9');
  697. entities.Add("kappa", '\u03BA');
  698. entities.Add("lambda", '\u03BB');
  699. entities.Add("mu", '\u03BC');
  700. entities.Add("nu", '\u03BD');
  701. entities.Add("xi", '\u03BE');
  702. entities.Add("omicron", '\u03BF');
  703. entities.Add("pi", '\u03C0');
  704. entities.Add("rho", '\u03C1');
  705. entities.Add("sigmaf", '\u03C2');
  706. entities.Add("sigma", '\u03C3');
  707. entities.Add("tau", '\u03C4');
  708. entities.Add("upsilon", '\u03C5');
  709. entities.Add("phi", '\u03C6');
  710. entities.Add("chi", '\u03C7');
  711. entities.Add("psi", '\u03C8');
  712. entities.Add("omega", '\u03C9');
  713. entities.Add("thetasym", '\u03D1');
  714. entities.Add("upsih", '\u03D2');
  715. entities.Add("piv", '\u03D6');
  716. entities.Add("bull", '\u2022');
  717. entities.Add("hellip", '\u2026');
  718. entities.Add("prime", '\u2032');
  719. entities.Add("Prime", '\u2033');
  720. entities.Add("oline", '\u203E');
  721. entities.Add("frasl", '\u2044');
  722. entities.Add("weierp", '\u2118');
  723. entities.Add("image", '\u2111');
  724. entities.Add("real", '\u211C');
  725. entities.Add("trade", '\u2122');
  726. entities.Add("alefsym", '\u2135');
  727. entities.Add("larr", '\u2190');
  728. entities.Add("uarr", '\u2191');
  729. entities.Add("rarr", '\u2192');
  730. entities.Add("darr", '\u2193');
  731. entities.Add("harr", '\u2194');
  732. entities.Add("crarr", '\u21B5');
  733. entities.Add("lArr", '\u21D0');
  734. entities.Add("uArr", '\u21D1');
  735. entities.Add("rArr", '\u21D2');
  736. entities.Add("dArr", '\u21D3');
  737. entities.Add("hArr", '\u21D4');
  738. entities.Add("forall", '\u2200');
  739. entities.Add("part", '\u2202');
  740. entities.Add("exist", '\u2203');
  741. entities.Add("empty", '\u2205');
  742. entities.Add("nabla", '\u2207');
  743. entities.Add("isin", '\u2208');
  744. entities.Add("notin", '\u2209');
  745. entities.Add("ni", '\u220B');
  746. entities.Add("prod", '\u220F');
  747. entities.Add("sum", '\u2211');
  748. entities.Add("minus", '\u2212');
  749. entities.Add("lowast", '\u2217');
  750. entities.Add("radic", '\u221A');
  751. entities.Add("prop", '\u221D');
  752. entities.Add("infin", '\u221E');
  753. entities.Add("ang", '\u2220');
  754. entities.Add("and", '\u2227');
  755. entities.Add("or", '\u2228');
  756. entities.Add("cap", '\u2229');
  757. entities.Add("cup", '\u222A');
  758. entities.Add("int", '\u222B');
  759. entities.Add("there4", '\u2234');
  760. entities.Add("sim", '\u223C');
  761. entities.Add("cong", '\u2245');
  762. entities.Add("asymp", '\u2248');
  763. entities.Add("ne", '\u2260');
  764. entities.Add("equiv", '\u2261');
  765. entities.Add("le", '\u2264');
  766. entities.Add("ge", '\u2265');
  767. entities.Add("sub", '\u2282');
  768. entities.Add("sup", '\u2283');
  769. entities.Add("nsub", '\u2284');
  770. entities.Add("sube", '\u2286');
  771. entities.Add("supe", '\u2287');
  772. entities.Add("oplus", '\u2295');
  773. entities.Add("otimes", '\u2297');
  774. entities.Add("perp", '\u22A5');
  775. entities.Add("sdot", '\u22C5');
  776. entities.Add("lceil", '\u2308');
  777. entities.Add("rceil", '\u2309');
  778. entities.Add("lfloor", '\u230A');
  779. entities.Add("rfloor", '\u230B');
  780. entities.Add("lang", '\u2329');
  781. entities.Add("rang", '\u232A');
  782. entities.Add("loz", '\u25CA');
  783. entities.Add("spades", '\u2660');
  784. entities.Add("clubs", '\u2663');
  785. entities.Add("hearts", '\u2665');
  786. entities.Add("diams", '\u2666');
  787. entities.Add("quot", '\u0022');
  788. entities.Add("amp", '\u0026');
  789. entities.Add("lt", '\u003C');
  790. entities.Add("gt", '\u003E');
  791. entities.Add("OElig", '\u0152');
  792. entities.Add("oelig", '\u0153');
  793. entities.Add("Scaron", '\u0160');
  794. entities.Add("scaron", '\u0161');
  795. entities.Add("Yuml", '\u0178');
  796. entities.Add("circ", '\u02C6');
  797. entities.Add("tilde", '\u02DC');
  798. entities.Add("ensp", '\u2002');
  799. entities.Add("emsp", '\u2003');
  800. entities.Add("thinsp", '\u2009');
  801. entities.Add("zwnj", '\u200C');
  802. entities.Add("zwj", '\u200D');
  803. entities.Add("lrm", '\u200E');
  804. entities.Add("rlm", '\u200F');
  805. entities.Add("ndash", '\u2013');
  806. entities.Add("mdash", '\u2014');
  807. entities.Add("lsquo", '\u2018');
  808. entities.Add("rsquo", '\u2019');
  809. entities.Add("sbquo", '\u201A');
  810. entities.Add("ldquo", '\u201C');
  811. entities.Add("rdquo", '\u201D');
  812. entities.Add("bdquo", '\u201E');
  813. entities.Add("dagger", '\u2020');
  814. entities.Add("Dagger", '\u2021');
  815. entities.Add("permil", '\u2030');
  816. entities.Add("lsaquo", '\u2039');
  817. entities.Add("rsaquo", '\u203A');
  818. entities.Add("euro", '\u20AC');
  819. }
  820. }
  821. }