Skip to content

Commit 650c2c1

Browse files
ucirellobradfitz
authored andcommitted
mime/quotedprintable: add examples
Partially addresses #16360 Change-Id: Ic098d2c465742fb50aee325a3fd0e1d50b7b3c99 Reviewed-on: https://go-review.googlesource.com/25575 Reviewed-by: Brad Fitzpatrick <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 967fa42 commit 650c2c1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2016 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+
5+
package quotedprintable_test
6+
7+
import (
8+
"fmt"
9+
"io/ioutil"
10+
"mime/quotedprintable"
11+
"os"
12+
"strings"
13+
)
14+
15+
func ExampleNewReader() {
16+
for _, s := range []string{
17+
`=48=65=6C=6C=6F=2C=20=47=6F=70=68=65=72=73=21`,
18+
`invalid escape: =B`,
19+
"Hello, Gophers! This symbol will be unescaped: =3D and this will be written in =\r\none line.",
20+
} {
21+
b, err := ioutil.ReadAll(quotedprintable.NewReader(strings.NewReader(s)))
22+
fmt.Printf("%s %v\n", b, err)
23+
}
24+
// Output:
25+
// Hello, Gophers! <nil>
26+
// invalid escape: unexpected EOF
27+
// Hello, Gophers! This symbol will be unescaped: = and this will be written in one line. <nil>
28+
}
29+
30+
func ExampleNewWriter() {
31+
w := quotedprintable.NewWriter(os.Stdout)
32+
w.Write([]byte("These symbols will be escaped: = \t"))
33+
w.Close()
34+
35+
// Output:
36+
// These symbols will be escaped: =3D =09
37+
}

0 commit comments

Comments
 (0)