WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

String Manipulation

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

udfHTMLEncode

 Keywords: Encode TEXT  HTML 

#DefineFunction udfHTMLEncode(text)
   oRegExp = ObjectCreate("VBScript.RegExp") ; Creates a regular expression object for use by WinBatch.
   oRegExp.Pattern = "[ a-zA-Z0-9]"  ; Required to establish a regular expression pattern to use in searching.
   sHtml = ""
   For x = 1 To StrLen(text)
      char = StrSub( text, x, 1)
      If ! oRegExp.Test(char)
          char = "&#" : Char2Num(char) : ";"
      EndIf
      sHtml = sHtml : char
   Next
   oRegExp = 0
   Return sHtml
#EndFunction

file = 'D:\temp\test.html'
html = udfHTMLEncode("This is a test: ! < > &")
FilePut( file, html )
Run( file, '')


Article ID:   W18393
Filename:   udfHTMLEncode.txt
File Created: 2009:03:11:13:59:52
Last Updated: 2009:03:11:13:59:52