const ( // BEncoding represents Base64 encoding scheme as defined by RFC 2045. BEncoding = WordEncoder('b') // QEncoding represents the Q-encoding scheme as defined by RFC 2047. QEncoding = WordEncoder('q') )
Reader is a quoted-printable decoder.
type Reader struct {
// contains filtered or unexported fields
}
func NewReader(r io.Reader) *Reader
NewReader returns a quoted-printable reader, decoding from r.
func (r *Reader) Read(p []byte) (n int, err error)
Read reads and decodes quoted-printable data from the underlying reader.
A WordDecoder decodes MIME headers containing RFC 2047 encoded-words.
type WordDecoder struct { // CharsetReader, if non-nil, defines a function to generate // charset-conversion readers, converting from the provided // charset into UTF-8. // Charsets are always lower-case. utf-8, iso-8859-1 and us-ascii charsets // are handled by default. // One of the the CharsetReader's result values must be non-nil. CharsetReader func(charset string, input io.Reader) (io.Reader, error) }
func (d *WordDecoder) Decode(word string) (string, error)
Decode decodes an encoded-word. If word is not a valid RFC 2047 encoded-word, word is returned unchanged.
▹ Example
func (d *WordDecoder) DecodeHeader(header string) (string, error)
DecodeHeader decodes all encoded-words of the given string. It returns an error if and only if CharsetReader of d returns an error.
▹ Example
A WordEncoder is a RFC 2047 encoded-word encoder.
type WordEncoder byte
func (e WordEncoder) Encode(charset, s string) string
Encode returns the encoded-word form of s. If s is ASCII without special characters, it is returned unchanged. The provided charset is the IANA charset name of s. It is case insensitive.
▹ Example
A Writer is a quoted-printable writer that implements io.WriteCloser.
type Writer struct { // Binary mode treats the writer's input as pure binary and processes end of // line bytes as binary data. Binary bool // contains filtered or unexported fields }
func NewWriter(w io.Writer) *Writer
NewWriter returns a new Writer that writes to w.
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 (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.