html.go 669 B

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