E
expertware
Dear friend as a routine to replace special character when one has to
output text on a web page (client side) I have used this one as a quick
and dirty way:
---------------------------------------------------------------------
Dim WebSymbols As String() = New String() { _
"&", "&", _
">", ">", _
"<", "<", _
(...Long list omitted...)
"û", "û", _
"ü", "ü", _
"ý", "ý", _
"þ", "þ", _
"ÿ", "ÿ", _
" ", " ", _
vbCrLf, "<br>" _
}
'Note: & must precede all, <br> must follow > <
Public Function FixStringForWEB(ByVal Text As String) As String
Dim WebText As New System.Text.StringBuilder(Text)
For i As Integer = 0 To WebSymbols.Length - 1 Step 2
WebText = WebText.Replace(WebSymbols(i), WebSymbols(i + 1))
Next i
Return WebText.ToString
End Function
-------------------------------------------------------------
I feel this method is unsatisfactory and ackward. I am wondering
if anyone can suggest a method more elegant and especially faster
(although the above is not that slow).
-Pamela
output text on a web page (client side) I have used this one as a quick
and dirty way:
---------------------------------------------------------------------
Dim WebSymbols As String() = New String() { _
"&", "&", _
">", ">", _
"<", "<", _
(...Long list omitted...)
"û", "û", _
"ü", "ü", _
"ý", "ý", _
"þ", "þ", _
"ÿ", "ÿ", _
" ", " ", _
vbCrLf, "<br>" _
}
'Note: & must precede all, <br> must follow > <
Public Function FixStringForWEB(ByVal Text As String) As String
Dim WebText As New System.Text.StringBuilder(Text)
For i As Integer = 0 To WebSymbols.Length - 1 Step 2
WebText = WebText.Replace(WebSymbols(i), WebSymbols(i + 1))
Next i
Return WebText.ToString
End Function
-------------------------------------------------------------
I feel this method is unsatisfactory and ackward. I am wondering
if anyone can suggest a method more elegant and especially faster
(although the above is not that slow).
-Pamela