### Read Text File into List and convert

This an example of reading a textfile which has UTF-8 format into a list.
An entry is selected from the list and converted into HTML.
Example
`Private Sub Handle(req As ServletRequest, resp As ServletResponse)
Dim tr As TextReader
tr.Initialize2(File.OpenInput(File.DirApp, "Quotes.txt"), "UTF8")
Dim l As List = tr.ReadList
Dim tipofday As String = l.Get(Rnd(0, l.Size - 1))
resp.Write("

").Write(WebUtils.EscapeHtml(tipofday)).Write("

")
End Sub`
HTML Conversion Routine from WebUtils.bas
Note: Add more conversions if required.
`Public Sub EscapeHtml(Raw As String) As String
Dim sb As StringBuilder
sb.Initialize
For i = 0 To Raw.Length - 1
Dim C As Char = Raw.CharAt(i)
Select C
Case CRLF
sb.Append("
")
Case Chr(9)
sb.Append(" ")
Case QUOTE
sb.Append(""")
Case "'"
sb.Append("'")
Case "<"
sb.Append("<")
Case ">"
sb.Append(">")
Case "&"
sb.Append("&")
Case "ö"
sb.Append("ö")
Case "ä"
sb.Append("ä")
Case "ü"
sb.Append("ü")
Case "Ö"
sb.Append("Ö")
Case "Ä"
sb.Append("Ä")
Case "Ü"
sb.Append("Ü")
Case "ß"
sb.Append("ß")
Case Chr(8220)
sb.Append("“")
Case Chr(8221)
sb.Append("”")
Case Chr(63)
sb.Append("?")
Case Chr(96)
sb.Append("`")
Case Chr(39)
sb.Append("'")
Case Chr(8216)
sb.Append("‘")
Case Chr(8217)
sb.Append("’")
Case Else
sb.Append(C)
End Select
Next
Return sb.ToString
End Sub`

Changed: , Category: Files, File: T6C193M1390.htm, ID: 1390