Home

Add

Edit

Without Linenumbers

Code in Textfield

Diese Funktion setzt Einen Text in HTML-Kodierten Text um.
Dadurch werden Fehlerhafte TAG's im HTML-Quellcode vermieden.


Funktion
  1. Function HTML_Encode(V_Text As String, V_NoLineBreak As Ubyte = 0, V_ShortPrepare As Ubyte = 0, V_DoRealBreak As Ubyte = 0) As String
    
  2. Dim O As String
    
  3. Dim MX As Uinteger = Len(V_Text)
    
  4. For X As Uinteger = 1 To MX
    
  5.     Select Case V_Text[X - 1]
    
  6.         Case 0 To 8, 11 To 31
    
  7.         Case 10
    
  8.             If V_NoLineBreak = 0 Then
    
  9.                 O += "<br>" & Chr(13, 10)
    
  10.             Else: If V_DoRealBreak = 1 Then O += Chr(13, 10)
    
  11.             End If
    
  12.         Case Else
    
  13.             If V_ShortPrepare <> 0 Then O += Chr(V_Text[X - 1]): Exit Select
    
  14.             Select Case V_Text[X - 1]
    
  15.                 Case 34: O += "&quot;"
    
  16.                 Case 38: O += "&amp;"
    
  17.                 Case 60: O += "&lt;"
    
  18.                 Case 62: O += "&gt;"
    
  19.                 
    
  20.                 Case 161: O += "&iexcl;"
    
  21.                 Case 162: O += "&cent;"
    
  22.                 Case 163: O += "&pound;"
    
  23.                 Case 164: O += "&curren;"
    
  24.                 Case 165: O += "&yen;"
    
  25.                 Case 166: O += "&brvbar;"
    
  26.                 Case 167: O += "&sect;"
    
  27.                 Case 168: O += "&uml;"
    
  28.                 Case 169: O += "&copy;"
    
  29.                 Case 170: O += "&ordf;"
    
  30.                 Case 171: O += "&laquo;"
    
  31.                 Case 172: O += "&not;"
    
  32.                 Case 173: O += "&shy;"
    
  33.                 Case 174: O += "&reg;"
    
  34.                 Case 175: O += "&macr;"
    
  35.                 Case 176: O += "&deg;"
    
  36.                 Case 177: O += "&plusmn;"
    
  37.                 Case 178: O += "&sup2;"
    
  38.                 Case 179: O += "&sup3;"
    
  39.                 Case 180: O += "&acute;"
    
  40.                 Case 181: O += "&micro;"
    
  41.                 Case 182: O += "&para;"
    
  42.                 Case 183: O += "&middot;"
    
  43.                 Case 184: O += "&cedil;"
    
  44.                 Case 185: O += "&sup1;"
    
  45.                 Case 186: O += "&ordm;"
    
  46.                 Case 187: O += "&raquo;"
    
  47.                 Case 188: O += "&frac14;"
    
  48.                 Case 189: O += "&frac12;"
    
  49.                 Case 190: O += "&frac34;"
    
  50.                 Case 191: O += "&iquest;"
    
  51.                 Case 192: O += "&Agrave;"
    
  52.                 Case 193: O += "&Aacute;"
    
  53.                 Case 194: O += "&Acirc;"
    
  54.                 Case 195
    
  55.                     If X < MX Then
    
  56.                         Select Case V_Text[X]
    
  57.                             Case 182:   O += "&ouml;": X += 1
    
  58.                             Case 150:   O += "&Ouml;": X += 1
    
  59.                             Case 188:   O += "&uuml;": X += 1
    
  60.                             Case 156:   O += "&Uuml;": X += 1
    
  61.                             Case 164:   O += "&auml;": X += 1
    
  62.                             Case 132:   O += "&Auml;": X += 1
    
  63.                             Case 159:   O += "&szlig;": X += 1
    
  64.                             Case Else:  Print V_Text[X]: O += "&Atilde;"
    
  65.                         End Select
    
  66.                     Else: O += "&Atilde;"
    
  67.                     End If
    
  68.                     
    
  69.                 Case 196: O += "&Auml;"
    
  70.                 Case 197: O += "&Aring;"
    
  71.                 Case 198: O += "&AElig;"
    
  72.                 Case 199: O += "&Ccedil;"
    
  73.                 Case 200: O += "&Egrave;"
    
  74.                 Case 201: O += "&Eacute;"
    
  75.                 Case 202: O += "&Ecirc;"
    
  76.                 Case 203: O += "&Euml;"
    
  77.                 Case 204: O += "&Igrave;"
    
  78.                 Case 205: O += "&Iacute;"
    
  79.                 Case 206: O += "&Icirc;"
    
  80.                 Case 207: O += "&Iuml;"
    
  81.                 Case 208: O += "&ETH;"
    
  82.                 Case 209: O += "&Ntilde;"
    
  83.                 Case 210: O += "&Ograve;"
    
  84.                 Case 211: O += "&Oacute;"
    
  85.                 Case 212: O += "&Ocirc;"
    
  86.                 Case 213: O += "&Otilde;"
    
  87.                 Case 214: O += "&Ouml;"
    
  88.                 Case 215: O += "&times;"
    
  89.                 Case 216: O += "&Oslash;"
    
  90.                 Case 217: O += "&Ugrave;"
    
  91.                 Case 218: O += "&Uacute;"
    
  92.                 Case 219: O += "&Ucirc;"
    
  93.                 Case 220: O += "&Uuml;"
    
  94.                 Case 221: O += "&Yacute;"
    
  95.                 Case 222: O += "&THORN;"
    
  96.                 Case 223: O += "&szlig;"
    
  97.                 Case 224: O += "&agrave;"
    
  98.                 Case 225: O += "&aacute;"
    
  99.                 Case 226: O += "&acirc;"
    
  100.                 Case 227: O += "&atilde;"
    
  101.                 Case 228: O += "&auml;"
    
  102.                 Case 229: O += "&aring;"
    
  103.                 Case 230: O += "&aelig;"
    
  104.                 Case 231: O += "&ccedil;"
    
  105.                 Case 232: O += "&egrave;"
    
  106.                 Case 233: O += "&eacute;"
    
  107.                 Case 234: O += "&ecirc;"
    
  108.                 Case 235: O += "&euml;"
    
  109.                 Case 236: O += "&igrave;"
    
  110.                 Case 237: O += "&iacute;"
    
  111.                 Case 238: O += "&icirc;"
    
  112.                 Case 239: O += "&iuml;"
    
  113.                 Case 240: O += "&eth;"
    
  114.                 Case 241: O += "&ntilde;"
    
  115.                 Case 242: O += "&ograve;"
    
  116.                 Case 243: O += "&oacute;"
    
  117.                 Case 244: O += "&ocirc;"
    
  118.                 Case 245: O += "&otilde;"
    
  119.                 Case 246: O += "&ouml;"
    
  120.                 Case 247: O += "&divide;"
    
  121.                 Case 248: O += "&oslash;"
    
  122.                 Case 249: O += "&ugrave;"
    
  123.                 Case 250: O += "&uacute;"
    
  124.                 Case 251: O += "&ucirc;"
    
  125.                 Case 252: O += "&uuml;"
    
  126.                 Case 253: O += "&yacute;"
    
  127.                 Case 254: O += "&thorn;"
    
  128.                 Case 255: O += "&yuml;"
    
  129.                 Case Else: O += Chr(V_Text[X - 1])
    
  130.         End Select
    
  131.     End Select
    
  132. Next
    
  133. Return O
    
  134. End Function
    




Beispiel
  1. Dim T As String = "<Hallo> Wie geht es dir? <b>Gut</b>"
    
  2. Print "Original: "; T
    
  3. Print "Kodiert:  "; HTML_Encode(T)
    




MfG
TPM