example_test.go 619 B

12345678910111213141516171819202122
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package html_test
  5. import (
  6. "fmt"
  7. "html"
  8. )
  9. func ExampleEscapeString() {
  10. const s = `"Fran & Freddie's Diner" <tasty@example.com>`
  11. fmt.Println(html.EscapeString(s))
  12. // Output: &#34;Fran &amp; Freddie&#39;s Diner&#34; &lt;tasty@example.com&gt;
  13. }
  14. func ExampleUnescapeString() {
  15. const s = `&quot;Fran &amp; Freddie&#39;s Diner&quot; &lt;tasty@example.com&gt;`
  16. fmt.Println(html.UnescapeString(s))
  17. // Output: "Fran & Freddie's Diner" <tasty@example.com>
  18. }