Convert HTML text into DB-safe string, by converting some characters as below.
Cannot believe that I do not have this here before now.
Replacing ' {{$Q$}}
Replacing " with {{$QQ$}}
Replacing \ with {{$BS$}}
Replacing / with {{$FS$}}
Replacing > with {{$GT$}}
Replacing < with {{$LT$}}
And back
Those two has t be used together everytime we read from or save into DB
Function ANma_HTML2DB(strHTML)
' Convert string from HTML to be saved safly into DB
' Replacing {{$Q$}} with '
' Replacing {{$QQ$}} with "
' Replacing {{$BS$}} with \
' Replacing {{$FS$}} with /
' Replacing {{$GT$}} with >
' Replacing {{$LT$}} with <
Rett = Replace(strHTML, "'", "{{$Q$}}")
Rett = Replace(Rett, """", "{{$QQ$}}")
Rett = Replace(Rett, "\", "{{$BS$}}")
Rett = Replace(Rett, "/", "{{$FS$}}")
Rett = Replace(Rett, ">", "{{$GT$}}")
Rett = Replace(Rett, "<", "{{$LT$}}")
Rett = Replace(Rett, "", "")
ANma_HTML2DB = Rett
End Function
Function ANma_DB2HTML(strDB)
' Convert string from DB (converted through ANma_HtmL2DB, into its HTML value
' Replacing {{$Q$}} with '
' Replacing {{$QQ$}} with "
' Replacing {{$BS$}} with \
' Replacing {{$FS$}} with /
' Replacing {{$GT$}} with >
' Replacing {{$LT$}} with <
'
Rett = Replace(strDB, "{{$Q$}}", "'")
Rett = Replace(Rett, "{{$QQ$}}", """")
Rett = Replace(Rett, "{{$BS$}}", "\")
Rett = Replace(Rett, "{{$FS$}}", "/")
Rett = Replace(Rett, "{{$GT$}}", ">")
Rett = Replace(Rett, "{{$LT$}}", "<")
Rett = Replace(Rett, "", "")
ANma_DB2HTML = Rett
End Function
' Convert string from HTML to be saved safly into DB
' Replacing {{$Q$}} with '
' Replacing {{$QQ$}} with "
' Replacing {{$BS$}} with \
' Replacing {{$FS$}} with /
' Replacing {{$GT$}} with >
' Replacing {{$LT$}} with <
Rett = Replace(strHTML, "'", "{{$Q$}}")
Rett = Replace(Rett, """", "{{$QQ$}}")
Rett = Replace(Rett, "\", "{{$BS$}}")
Rett = Replace(Rett, "/", "{{$FS$}}")
Rett = Replace(Rett, ">", "{{$GT$}}")
Rett = Replace(Rett, "<", "{{$LT$}}")
Rett = Replace(Rett, "", "")
ANma_HTML2DB = Rett
End Function
Function ANma_DB2HTML(strDB)
' Convert string from DB (converted through ANma_HtmL2DB, into its HTML value
' Replacing {{$Q$}} with '
' Replacing {{$QQ$}} with "
' Replacing {{$BS$}} with \
' Replacing {{$FS$}} with /
' Replacing {{$GT$}} with >
' Replacing {{$LT$}} with <
'
Rett = Replace(strDB, "{{$Q$}}", "'")
Rett = Replace(Rett, "{{$QQ$}}", """")
Rett = Replace(Rett, "{{$BS$}}", "\")
Rett = Replace(Rett, "{{$FS$}}", "/")
Rett = Replace(Rett, "{{$GT$}}", ">")
Rett = Replace(Rett, "{{$LT$}}", "<")
Rett = Replace(Rett, "", "")
ANma_DB2HTML = Rett
End Function
strHTML
or
strDB
or
strDB
Views 1723 Downloads 671
db
| convert
| replace
| substitute
| html
| removehtml
| removehtmltag
| str2db
| 2db
| safe
| save
| tag
| tags
| app2db
| db2str


ANmarAmdeen
660
Revisions
v1.0
Tags
db, convert, replace, substitute, html, removehtml, removehtmltag, str2db, 2db, safe, save, tag, tags, app2db, db2str