Convert HTML code subroutine

xiaoxiao2021-03-06  114

? Author:?

?? function htmlencode (str) ??? on error resume next ??? Dim Result ??? Dim L ??? if isnull (str) THEN ?????? htmlencode = "" ?????? EXIT Function ??? Endiff

??? l = len (str) ??? result = "" DIM IFOR i = 1 to L ??? SELECT CASE MID (STR, I, 1) ?????????? Case "<" ??????????????? result = result "<" ?????????? case ">" ???????????????????????????? Result = result ">" ?????????? case chr (34) ???????????????? = result "" "" "" ???????? ?? Case "&" ??????????????? result = result "&" ?????????? case chr (13) ???????? ??????? result = result "" ?????????? case chr (9) ??????????????? result = result "??? ??????? case chr (32) ?????????????????????????? "????? ????????? IF i 1 <= l and i-1> 0 THEN ????????????????? IF MID (STR, I 1, 1) = CHR (32) OR MID (STR, I 1, 1) = CHR (9) or MID (STR, I-1, 1) = CHR (32) or MID (STR, I-1, 1) = CHR (9)? Then ???????????????????????????????????? Result = result "" ????????????????????????????????? = result "" ??????????????????? End if ?????????????????????? ???? result = result "?????????????????????????? End if ???? ?????? case else ??????????????? result = results MID (STR, I, 1) ??????? end select ????? ? Next ?????? if err.number <> 0 t Hen err.clear ?????? htmlencode = result ?? End function

?

转载请注明原文地址:https://www.9cbs.com/read-125892.html

New Post(0)