VBScript htmlspecialchars function

A VBScript equivalent of PHP’s htmlspecialchars


Const ENT_NOQUOTES = 0
Const ENT_COMPAT   = 2
Const ENT_QUOTES   = 3
Function htmlSpecialChars(ByVal str)

    if len( str ) > 0 then
        str = Server.HTMLEncode(str)
        str = Replace(str,"'","'")
    end if
    htmlspecialchars = str

End Function

Please also note that php.vbs offers community built functions and goes by the McDonald’s Theory. We’ll put online functions that are far from perfect, in the hopes to spark better contributions. Do you have one? Then please just:

Other PHP functions in the strings extension