i try to find a way to convert a string in html entities
since i don't find any easy solution, i write this
did anybody know a better way to do it ?
since i don't find any easy solution, i write this
did anybody know a better way to do it ?
B4X:
Sub htmlentities(tc As String) As String
Dim res,testc As String
Dim n As Int
res=""
For n=0 To tc.Length-1
testc=tc.CharAt(n)
Select tc
Case Chr(0022)
res=res&"""' quotation mark
Case "'"
res=res&"'"' apostrophe
Case "&"
res=res&"&"' ampersand
Case "<"
res=res&"<"' less-than
Case ">"
res=res&">"' greater-than
Case " "
res=res&" "' non-breaking space
Case "¡"
res=res&"¡"' inverted exclamation mark
Case "¢"
res=res&"¢"' cent
Case "£"
res=res&"£"' pound
Case "¤"
res=res&"¤"' currency
Case "¥"
res=res&"¥"' yen
Case "¦"
res=res&"¦"' broken vertical bar
Case "§"
res=res&"§"' section
case "¨"
res=res&"¨"' spacing diaeresis
case "©"
res=res&"©"' copyright
case "ª"
res=res&"ª"' feminine ordinal indicator
case "«"
res=res&"«"' angle quotation mark (left)
case "¬"
res=res&"¬"' negation
case "®"
res=res&"®"' registered trademark
case "¯"
res=res&"¯"' spacing macron
case "°"
res=res&"°"' degree
case "±"
res=res&"±"' plus-or-minus
case "²"
res=res&"²"' superscript 2
case "³"
res=res&"³"' superscript 3
case "´"
res=res&"´"' spacing acute
case "µ"
res=res&"µ"' micro
case "¶"
res=res&"¶"' paragraph
case "·"
res=res&"·"' middle dot
case "¸"
res=res&"¸"' spacing cedilla
case "¹"
res=res&"¹"' superscript 1
case "º"
res=res&"º"' masculine ordinal indicator
case "»"
res=res&"»"' angle quotation mark (right)
case "¼"
res=res&"¼"' fraction 1/4
case "½"
res=res&"½"' fraction 1/2
case "¾"
res=res&"¾"' fraction 3/4
case "¿"
res=res&"¿"' inverted question mark
case "×"
res=res&"×"' multiplication
case "÷"
res=res&"÷"' division
case "À"
res=res&"À"' capital a, grave accent
case "Á"
res=res&"Á"' capital a, acute accent
case "Â"
res=res&"Â"' capital a, circumflex accent
case "Ã"
res=res&"Ã"' capital a, tilde
case "Ä"
res=res&"Ä"' capital a, umlaut mark
case "Å"
res=res&"Å"' capital a, ring
case "Æ"
res=res&"Æ"' capital ae
case "Ç"
res=res&"Ç"' capital c, cedilla
case "È"
res=res&"È"' capital e, grave accent
case "É"
res=res&"É"' capital e, acute accent
case "Ê"
res=res&"Ê"' capital e, circumflex accent
case "Ë"
res=res&"Ë"' capital e, umlaut mark
case "Ì"
res=res&"Ì"' capital i, grave accent
case "Í"
res=res&"Í"' capital i, acute accent
case "Î"
res=res&"Î"' capital i, circumflex accent
case "Ï"
res=res&"Ï"' capital i, umlaut mark
case "Ð"
res=res&"Ð"' capital eth, Icelandic
case "Ñ"
res=res&"Ñ"' capital n, tilde
case "Ò"
res=res&"Ò"' capital o, grave accent
case "Ó"
res=res&"Ó"' capital o, acute accent
case "Ô"
res=res&"Ô"' capital o, circumflex accent
case "Õ"
res=res&"Õ"' capital o, tilde
case "Ö"
res=res&"Ö"' capital o, umlaut mark
case "Ø"
res=res&"Ø"' capital o, slash
case "Ù"
res=res&"Ù"' capital u, grave accent
case "Ú"
res=res&"Ú"' capital u, acute accent
case "Û"
res=res&"Û"' capital u, circumflex accent
case "Ü"
res=res&"Ü"' capital u, umlaut mark
case "Ý"
res=res&"Ý"' capital y, acute accent
case "Þ"
res=res&"Þ"' capital THORN, Icelandic
case "ß"
res=res&"ß"' small sharp s, German
case "à"
res=res&"à"' small a, grave accent
case "á"
res=res&"á"' small a, acute accent
case "â"
res=res&"â"' small a, circumflex accent
case "ã"
res=res&"ã"' small a, tilde
case "ä"
res=res&"ä"' small a, umlaut mark
case "å"
res=res&"å"' small a, ring
case "æ"
res=res&"æ"' small ae
case "ç"
res=res&"ç"' small c, cedilla
case "è"
res=res&"è"' small e, grave accent
case "é"
res=res&"é"' small e, acute accent
case "ê"
res=res&"ê"' small e, circumflex accent
case "ë"
res=res&"ë"' small e, umlaut mark
case "ì"
res=res&"ì"' small i, grave accent
case "í"
res=res&"í"' small i, acute accent
case "î"
res=res&"î"' small i, circumflex accent
case "ï"
res=res&"ï"' small i, umlaut mark
case "ð"
res=res&"ð"' small eth, Icelandic
case "ñ"
res=res&"ñ"' small n, tilde
case "ò"
res=res&"ò"' small o, grave accent
case "ó"
res=res&"ó"' small o, acute accent
case "ô"
res=res&"ô"' small o, circumflex accent
case "õ"
res=res&"õ"' small o, tilde
case "ö"
res=res&"ö"' small o, umlaut mark
case "ø"
res=res&"ø"' small o, slash
case "ù"
res=res&"ù"' small u, grave accent
case "ú"
res=res&"ú"' small u, acute accent
case "û"
res=res&"û"' small u, circumflex accent
case "ü"
res=res&"ü"' small u, umlaut mark
case "ý"
res=res&"ý"' small y, acute accent
case "þ"
res=res&"þ"' small thorn, Icelandic
case "ÿ"
res=res&"ÿ"' small y, umlaut mark
case "€"
res=res&"€"
Case "™"
res=res&"™"
Case Else
res=res & testc
End Select
Next
Return res
End Sub