Text input with symbols January 25 2005
Recently I created an application that required the user’s ability to enter trademark and copyright symbols into text fields. There didn’t appear to be a problem at first since the symbols seemed to be preserved after processing but upon closed inspection using the string.replace() method, strange artifacts began appearing.
To solve this problem I wrote a quick function that would replace certain characters (as identified by there CHR() values) by common HTML.
Public Shared Function formatStringToHTML(ByVal strString As String) As String
Dim strNewString As String = strString
strNewString = strNewString.Replace(Chr(174), “®”)
strNewString = strNewString.Replace(Chr(153), “<sup style=”"font-size:8pt;”">TM</sup>”)
strNewString = strNewString.Replace(Chr(169), “©”)
Return strNewString
End Function
- Posted in : .NET
- Author : site admin

Comments
Sorry comments are closed for this entry