| 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" |
| 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 style="font-size: 200%">hello</b>`, |
| 19 |
"Hello, Gophers! This symbol will be unescaped: =3D and this will be written in =\r\none line.", |
| 20 |
} { |
| 21 |
b, err := io.ReadAll(quotedprintable.NewReader(strings.NewReader(s))) |
| 22 |
fmt.Printf("%s %v\n", b, err) |
| 23 |
} |
| 24 |
// Output: |
| 25 |
// Hello, Gophers! <nil> |
| 26 |
// invalid escape: <b style="font-size: 200%">hello</b> <nil> |
| 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 |
} |