FormatTxt Function:

The FormatTxt function applies special html characters to a string. FormatTxt uses special codes to delinate html characters. The following special characters are supported by FormatTxt:
recognized
character code
replaced by
[2] subscript 2 ²
[3] subscript 3 ³
[1] subscript 1 ¹
[0] subscript 0 º
[deg] degrees symbol °
[1/2] one-half ½
[3/4] three-quarters ¾
[1/4] one-quarter ¼
[tm] trademark ™
[c] copyright ©
[r] registered ®
[div] division sign ÷
[plusminus] Plus/Minus sign ±
[pounds] British Pound £
[cents] Cents sign ¢


Syntax:
string = FormatTxt(string)
Example Usage:
<%
dim a

 ' set up a string with some character codes in it ( everything between the []'s 
 ' will be replaced if it is recognized as a FormatTxt character code).

a =	"123[3] 1442[1] 211343[2] 112[DEG]F 14[1/2] 12[3/4] 634[1/4] " & _
	"this is copyright [C] and is a registered [R] trademark" & _
	"[TM]. 14[div]12  avg 4[plusminus]2 334[pounds] 65[cents]"

 ' write resultant string
response.write FormatTxt( a )
%>
The above example returns: 123³ 1442¹ 211343² 112°F 14½ 12¾ 634¼ this is copyright © and is a registered ® trademark™. 14÷12 avg 4±2 334£ 65¢
ASP Source Code:
<%
Private Function FormatTxt(byVal string)
	Const Delimiter1a = "[", Delimiter1b = "]"
	Dim a, b, c, d, strDel, strDel2
	strDel  = Delimiter1a : strDel2 = Delimiter1b
	a = instrrev( string, strDel ) : b = instrrev( string, strDel2 )
	c = Mid( string, a, b - a + 1)
	string = replace( string, c, lcase( c ) )
	d = CStr( c ) : d = LCase( c )
	Select Case LCase( d )
		Case strDel & "2" & strDel2
			string = Replace( string, d, chr( 178 ) )
		Case strDel & "3" & strDel2
			string = Replace( string, d, chr( 179 ) )
		Case strDel & "1" & strDel2
			string = Replace( string, d, chr( 185 ) )
		Case strDel & "0" & strDel2
			string = Replace( string, d, chr( 186 ) )
		Case strDel & "deg" & strDel2
			string = Replace( string, d, chr( 176 ) )
		Case strDel & "1/2" & strDel2
			string = Replace( string, d, chr( 189 ) )
		Case strDel & "3/4" & strDel2
			string = Replace( string, d, chr( 190 ) )
		Case strDel & "1/4" & strDel2
			string = Replace( string, d, chr( 188 ) )
		Case strDel & "tm" & strDel2
			string = Replace( string, d, chr( 153 ) )
		Case strDel & "c" & strDel2
			string = Replace( string, d, chr( 169 ) )
		Case strDel & "r" & strDel2
			string = Replace( string, d, chr( 174 ) )
		Case strDel & "div" & strDel2
			string = Replace( string, d, chr( 247 ) )
		Case strDel & "plusminus" & strDel2
			string = Replace( string, d, chr( 177 ) )
		Case strDel & "pounds" & strDel2
			string = Replace( string, d, chr( 163 ) )
		Case strDel & "cents" & strDel2
			string = Replace( string, d, chr( 162 ) )
	End Select
	if instr( string, Delimiter1a ) or instr( string, Delimiter1b ) then _
		string = FormatTxt( string )
	FormatTxt = string
End Function
%>