version: 1.10

package quotedprintable

import "mime/quotedprintable"

Overview

Package quotedprintable implements quoted-printable encoding as specified by RFC
2045.

Index

Examples

Package files

reader.go writer.go

type Reader

  1. type Reader struct {
  2. // contains filtered or unexported fields
  3. }

Reader is a quoted-printable decoder.

func NewReader

  1. func NewReader(r io.Reader) *Reader

NewReader returns a quoted-printable reader, decoding from r.


Example:

  1. for _, s := range []string{
  2. `=48=65=6C=6C=6F=2C=20=47=6F=70=68=65=72=73=21`,
  3. `invalid escape: <b style="font-size: 200%">hello</b>`,
  4. "Hello, Gophers! This symbol will be unescaped: =3D and this will be written in =\r\none line.",
  5. } {
  6. b, err := ioutil.ReadAll(quotedprintable.NewReader(strings.NewReader(s)))
  7. fmt.Printf("%s %v\n", b, err)
  8. }
  9. // Output:
  10. // Hello, Gophers! <nil>
  11. // invalid escape: <b style="font-size: 200%">hello</b> <nil>
  12. // Hello, Gophers! This symbol will be unescaped: = and this will be written in one line. <nil>

func (*Reader) Read

  1. func (r *Reader) Read(p []byte) (n int, err error)

Read reads and decodes quoted-printable data from the underlying reader.

type Writer

  1. type Writer struct {
  2. // Binary mode treats the writer's input as pure binary and processes end of
  3. // line bytes as binary data.
  4. Binary bool
  5. // contains filtered or unexported fields
  6. }

A Writer is a quoted-printable writer that implements io.WriteCloser.

func NewWriter

  1. func NewWriter(w io.Writer) *Writer

NewWriter returns a new Writer that writes to w.


Example:

  1. w := quotedprintable.NewWriter(os.Stdout)
  2. w.Write([]byte("These symbols will be escaped: = \t"))
  3. w.Close()
  4. // Output:
  5. // These symbols will be escaped: =3D =09

func (*Writer) Close

  1. func (w *Writer) Close() error

Close closes the Writer, flushing any unwritten data to the underlying
io.Writer, but does not close the underlying io.Writer.

func (*Writer) Write

  1. func (w *Writer) Write(p []byte) (n int, err error)

Write encodes p using quoted-printable encoding and writes it to the underlying
io.Writer. It limits line length to 76 characters. The encoded bytes are not
necessarily flushed until the Writer is closed.