html.go 673 B

123456789101112131415161718192021222324252627
  1. package web
  2. import (
  3. "strings"
  4. )
  5. // HTMLUnEscape html special char convert
  6. // &quot; to space, &amp; to &, &lt; to <, &gt; to >
  7. func HTMLUnEscape(url string) string {
  8. s := strings.Replace(url, "&quot;", "\"", -1)
  9. s = strings.Replace(s, "&amp;", "&", -1)
  10. s = strings.Replace(s, "&lt;", "<", -1)
  11. s = strings.Replace(s, "&gt;", ">", -1)
  12. return s
  13. }
  14. // HTMLEscape html special char convert
  15. // space to &quot;, & to &amp;, < to &lt;, > to &gt;
  16. func HTMLEscape(url string) string {
  17. s := strings.Replace(url, "\"", "&quot;", -1)
  18. s = strings.Replace(s, "&", "&amp;", -1)
  19. s = strings.Replace(s, "<", "&lt;", -1)
  20. s = strings.Replace(s, ">", "&gt;", -1)
  21. return s
  22. }