CSharp examples for System:String HTML
Decode Value as HTML
using System.Text; using System.IO;/* ww w . j a v a 2 s . c o m*/ using System.Globalization; using System; public class Main{ public static string DecodeValue(string value) { StringBuilder builder = new StringBuilder(); StringReader reader = new StringReader(value); int num = reader.Read(); while (num != -1) { StringBuilder builder2 = new StringBuilder(); while ((num != 0x26) && (num != -1)) { builder2.Append((char)num); num = reader.Read(); } builder.Append(builder2.ToString()); if (num == 0x26) { builder2 = new StringBuilder(); while ((num != 0x3b) && (num != -1)) { builder2.Append((char)num); num = reader.Read(); } if (num == 0x3b) { num = reader.Read(); builder2.Append(';'); if (builder2[1] == '#') { int result = -1; if (int.TryParse(builder2.ToString().Substring(2, builder2.Length - 3), out result)) { builder.Append((char)result); } else if (int.TryParse(builder2.ToString().Substring(3, builder2.Length - 4), NumberStyles.HexNumber, null, out result)) { builder.Append((char)result); } } else { switch (builder2.ToString()) { case "<": { builder.Append("<"); continue; } case ">": { builder.Append(">"); continue; } case """: { builder.Append("\""); continue; } case "&": { builder.Append("&"); continue; } case "Á": { builder.Append('\x00c1'); continue; } case "á": { builder.Append('\x00e1'); continue; } case "Â": { builder.Append('\x00c2'); continue; } case "â": { builder.Append('\x00e2'); continue; } case "´": { builder.Append('\x00b4'); continue; } case "Æ": { builder.Append('\x00c6'); continue; } case "æ": { builder.Append('\x00e6'); continue; } case "À": { builder.Append('\x00c0'); continue; } case "à": { builder.Append('\x00e0'); continue; } case "ℵ": { builder.Append('?'); continue; } case "Α": { builder.Append('?'); continue; } case "α": { builder.Append('a'); continue; } case "∧": { builder.Append('?'); continue; } case "∠": { builder.Append('?'); continue; } case "Å": { builder.Append('\x00c5'); continue; } case "å": { builder.Append('\x00e5'); continue; } case "≈": { builder.Append('?'); continue; } case "Ã": { builder.Append('\x00c3'); continue; } case "ã": { builder.Append('\x00e3'); continue; } case "Ä": { builder.Append('\x00c4'); continue; } case "ä": { builder.Append('\x00e4'); continue; } case "„": { builder.Append('?'); continue; } case "Β": { builder.Append('?'); continue; } case "β": { builder.Append('?'); continue; } case "¦": { builder.Append('\x00a6'); continue; } case "•": { builder.Append('?'); continue; } case "∩": { builder.Append('n'); continue; } case "Ç": { builder.Append('\x00c7'); continue; } case "ç": { builder.Append('\x00e7'); continue; } case "¸": { builder.Append('\x00b8'); continue; } case "¢": { builder.Append('\x00a2'); continue; } case "Χ": { builder.Append('?'); continue; } case "χ": { builder.Append('?'); continue; } case "ˆ": { builder.Append('?'); continue; } case "♣": { builder.Append('?'); continue; } case "≅": { builder.Append('?'); continue; } case "©": { builder.Append('\x00a9'); continue; } case "↵": { builder.Append('?'); continue; } case "∪": { builder.Append('?'); continue; } case "¤": { builder.Append('\x00a4'); continue; } case "†": { builder.Append('?'); continue; } case "‡": { builder.Append('?'); continue; } case "↓": { builder.Append('?'); continue; } case "⇓": { builder.Append('?'); continue; } case "°": { builder.Append('\x00b0'); continue; } case "Δ": { builder.Append('?'); continue; } case "δ": { builder.Append('d'); continue; } case "♦": { builder.Append('?'); continue; } case "÷": { builder.Append('\x00f7'); continue; } case "É": { builder.Append('\x00c9'); continue; } case "é": { builder.Append('\x00e9'); continue; } case "Ê": { builder.Append('\x00ca'); continue; } case "ê": { builder.Append('\x00ea'); continue; } case "È": { builder.Append('\x00c8'); continue; } case "è": { builder.Append('\x00e8'); continue; } case "∅": { builder.Append('?'); continue; } case " ": { builder.Append(' '); continue; } case "Ε": { builder.Append('?'); continue; } case "ε": { builder.Append('e'); continue; } case "≡": { builder.Append('='); continue; } case "Η": { builder.Append('?'); continue; } case "η": { builder.Append('?'); continue; } case "Ð": { builder.Append('\x00d0'); continue; } case "ð": { builder.Append('\x00f0'); continue; } case "Ë": { builder.Append('\x00cb'); continue; } case "ë": { builder.Append('\x00eb'); continue; } case "€": { builder.Append('\x0080'); continue; } case "∃": { builder.Append('?'); continue; } case "ƒ": { builder.Append('?'); continue; } case "∀": { builder.Append('?'); continue; } case "½": { builder.Append('\x00bd'); continue; } case "¼": { builder.Append('\x00bc'); continue; } case "¾": { builder.Append('\x00be'); continue; } case "&fras1;": { builder.Append('?'); continue; } case "Γ": { builder.Append('G'); continue; } case "γ": { builder.Append('?'); continue; } case "≥": { builder.Append('='); continue; } case "↔": { builder.Append('?'); continue; } case "⇔": { builder.Append('?'); continue; } case "♥": { builder.Append('?'); continue; } case "…": { builder.Append('?'); continue; } case "Í": { builder.Append('\x00cd'); continue; } case "í": { builder.Append('\x00ed'); continue; } case "Î": { builder.Append('\x00ce'); continue; } case "î": { builder.Append('\x00ee'); continue; } case "¡": { builder.Append('\x00a1'); continue; } case "Ì": { builder.Append('\x00cc'); continue; } case "ì": { builder.Append('\x00ec'); continue; } case "ℑ": { builder.Append('I'); continue; } case "∞": { builder.Append('8'); continue; } case "∫": { builder.Append('?'); continue; } case "Ι": { builder.Append('?'); continue; } case "ι": { builder.Append('?'); continue; } case "¿": { builder.Append('\x00bf'); continue; } case "∈": { builder.Append('?'); continue; } case "Ï": { builder.Append('\x00cf'); continue; } case "ï": { builder.Append('\x00ef'); continue; } case "Κ": { builder.Append('?'); continue; } case "κ": { builder.Append('?'); continue; } case "Λ": { builder.Append('?'); continue; } case "λ": { builder.Append('?'); continue; } case "⟨": { builder.Append('<'); continue; } case "«": { builder.Append('\x00ab'); continue; } case "←": { builder.Append('?'); continue; } case "⇐": { builder.Append('?'); continue; } case "⌈": { builder.Append('?'); continue; } case "“": { builder.Append('?'); continue; } case "≤": { builder.Append('='); continue; } case "⌊": { builder.Append('?'); continue; } case "∗": { builder.Append('*'); continue; } case "◊": { builder.Append('?'); continue; } case "‎": { builder.Append('?'); continue; } case "‹": { builder.Append('?'); continue; } case "‘": { builder.Append('?'); continue; } case "¯": { builder.Append('\x00af'); continue; } case "—": { builder.Append('?'); continue; } case "µ": { builder.Append('\x00b5'); continue; } case "·": { builder.Append('\x00b7'); continue; } case "−": { builder.Append('-'); continue; } case "Μ": { builder.Append('?'); continue; } case "μ": { builder.Append('?'); continue; } case "∇": { builder.Append('?'); continue; } case " ": { builder.Append(' '); continue; } case "–": { builder.Append('?'); continue; } case "≠": { builder.Append('?'); continue; } case "∋": { builder.Append('?'); continue; } case "¬": { builder.Append('\x00ac'); continue; } case "∉": { builder.Append('?'); continue; } case "⊄": { builder.Append('?'); continue; } case "Ñ": { builder.Append('\x00d1'); continue; } case "ñ": { builder.Append('\x00f1'); continue; } case "Ν": { builder.Append('?'); continue; } case "ν": { builder.Append('?'); continue; } case "Ó": { builder.Append('\x00d3'); continue; } case "ó": { builder.Append('\x00f3'); continue; } case "Ô": { builder.Append('\x00d4'); continue; } case "ô": { builder.Append('\x00f4'); continue; } case "Œ": { builder.Append('?'); continue; } case "œ": { builder.Append('?'); continue; } case "Ò": { builder.Append('\x00d2'); continue; } case "ò": { builder.Append('\x00f2'); continue; } case "‾": { builder.Append('?'); continue; } case "Ω": { builder.Append('O'); continue; } case "ω": { builder.Append('?'); continue; } case "Ο": { builder.Append('?'); continue; } case "ο": { builder.Append('?'); continue; } case "⊕": { builder.Append('?'); continue; } case "∨": { builder.Append('?'); continue; } case "ª": { builder.Append('\x00aa'); continue; } case "º": { builder.Append('\x00ba'); continue; } case "Ø": { builder.Append('\x00d8'); continue; } case "ø": { builder.Append('\x00f8'); continue; } case "Õ": { builder.Append('\x00d5'); continue; } case "õ": { builder.Append('\x00f5'); continue; } case "⊗": { builder.Append('?'); continue; } case "Ö": { builder.Append('\x00d6'); continue; } case "ö": { builder.Append('\x00f6'); continue; } case "¶": { builder.Append('\x00b6'); continue; } case "∂": { builder.Append('?'); continue; } case "‰": { builder.Append('?'); continue; } case "⊥": { builder.Append('?'); continue; } case "Φ": { builder.Append('F'); continue; } case "φ": { builder.Append('f'); continue; } case "Π": { builder.Append('?'); continue; } case "π": { builder.Append('p'); continue; } case "ϖ": { builder.Append('?'); continue; } case "±": { builder.Append('\x00b1'); continue; } case "£": { builder.Append('\x00a3'); continue; } case "′": { builder.Append('''); continue; } case "″": { builder.Append('?'); continue; } case "∏": { builder.Append('?'); continue; } case "∝": { builder.Append('?'); continue; } case "Ψ": { builder.Append('?'); continue; } case "ψ": { builder.Append('?'); continue; } case "√": { builder.Append('v'); continue; } case "⟩": { builder.Append('>'); continue; } case "»": { builder.Append('\x00bb'); continue; } case "→": { builder.Append('?'); continue; } case "⇒": { builder.Append('?'); continue; } case "⌉": { builder.Append('?'); continue; } case "”": { builder.Append('?'); continue; } case "ℜ": { builder.Append('R'); continue; } case "®": { builder.Append('\x00ae'); continue; } case "⌋": { builder.Append('?'); continue; } case "Ρ": { builder.Append('?'); continue; } case "ρ": { builder.Append('?'); continue; } case "‏": { builder.Append('?'); continue; } case "›": { builder.Append('?'); continue; } case "’": { builder.Append('?'); continue; } case "‚": { builder.Append('?'); continue; } case "Š": { builder.Append('?'); continue; } case "š": { builder.Append('?'); continue; } case "⋅": { builder.Append('?'); continue; } case "§": { builder.Append('\x00a7'); continue; } case "­": { builder.Append('\x00ad'); continue; } case "Σ": { builder.Append('S'); continue; } case "σ": { builder.Append('s'); continue; } case "ς": { builder.Append('?'); continue; } case "∼": { builder.Append('~'); continue; } case "♠": { builder.Append('?'); continue; } case "⊂": { builder.Append('?'); continue; } case "⊆": { builder.Append('?'); continue; } case "∑": { builder.Append('?'); continue; } case "⊃": { builder.Append('?'); continue; } case "¹": { builder.Append('\x00b9'); continue; } case "²": { builder.Append('\x00b2'); continue; } case "³": { builder.Append('\x00b3'); continue; } case "⊇": { builder.Append('?'); continue; } case "ß": { builder.Append('\x00df'); continue; } case "Τ": { builder.Append('?'); continue; } case "τ": { builder.Append('t'); continue; } case "∴": { builder.Append('?'); continue; } case "Θ": { builder.Append('T'); continue; } case "θ": { builder.Append('?'); continue; } case "ϑ": { builder.Append('?'); continue; } case " ": { builder.Append('?'); continue; } case "Þ": { builder.Append('\x00de'); continue; } case "þ": { builder.Append('\x00fe'); continue; } case "˜": { builder.Append('?'); continue; } case "×": { builder.Append('\x00d7'); continue; } case "™": { builder.Append('?'); continue; } case "Ú": { builder.Append('\x00da'); continue; } case "ú": { builder.Append('\x00fa'); continue; } case "↑": { builder.Append('?'); continue; } case "⇑": { builder.Append('?'); continue; } case "Û": { builder.Append('\x00db'); continue; } case "û": { builder.Append('\x00fb'); continue; } case "Ù": { builder.Append('\x00d9'); continue; } case "ù": { builder.Append('\x00f9'); continue; } case "¨": { builder.Append('\x00a8'); continue; } case "ϒ": { builder.Append('?'); continue; } case "Υ": { builder.Append('?'); continue; } case "υ": { builder.Append('?'); continue; } case "Ü": { builder.Append('\x00dc'); continue; } case "ü": { builder.Append('\x00fc'); continue; } case "℘": { builder.Append('P'); continue; } case "Ξ": { builder.Append('?'); continue; } case "ξ": { builder.Append('?'); continue; } case "Ý": { builder.Append('\x00dd'); continue; } case "ý": { builder.Append('\x00fd'); continue; } case "¥": { builder.Append('\x00a5'); continue; } case "Ÿ": { builder.Append('?'); continue; } case "ÿ": { builder.Append('\x00ff'); continue; } case "Ζ": { builder.Append('?'); continue; } case "ζ": { builder.Append('?'); continue; } case "‍": { builder.Append('?'); continue; } case "‌": { builder.Append('?'); continue; } } builder.Append(builder2.ToString()); } } else { builder.Append(builder2.ToString()); } } } return builder.ToString(); } }