decode

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package decode provides byte stream filters to convert or assert form of mail-related data.

Index

Constants

This section is empty.

Variables

View Source
var ErrImproperUTF8 = errors.New("improper UTF-8")

Functions

func Charset

func Charset(charset string, r io.Reader) (io.Reader, error)

Charsets "" and "us-ascii" are generously interpreted as "utf-8".

func FixUTF8

func FixUTF8(data []byte) []byte

func Flow

func Flow(format, delsp string, r io.Reader) io.Reader

Cf. RFC 3676

func IsTerminalFriendly

func IsTerminalFriendly(r rune) bool

func MailHeader

func MailHeader(rawmailheader string) (string, error)

func TerminalFriendly

func TerminalFriendly(r io.Reader) io.Reader

[2023-02-15, jfrech] One spam mail I viewed was encoded in UTF-8 yet claimed "charset=iso-8859-1". Thus, a UTF-8 sharp s "ß" got (correctly) decoded to "Ã\u009F", abruptly cutting of my terminal emulator's representation of stdout.

func Transfer

func Transfer(r io.Reader, encodings ...string) (io.Reader, error)

Transfer decodes the given reader, last encoding applied first. Transfer is trying to be lenient: it may assume UTF-8 on e.g. undeclared Latin-1 input and thus create unicode/utf8.RuneError.

encodings are applied in reverse (i.e. the order of encodings is the same as the order would be in a generalised "Content-Transfer-Encoding" header).

func UTF8

func UTF8(lenient bool, r io.Reader) io.Reader

Types

type AustereReader

type AustereReader struct {
	// contains filtered or unexported fields
}

func Eightbit

func Eightbit(r io.Reader) *AustereReader

func Sevenbit

func Sevenbit(r io.Reader) *AustereReader

func StrictlyEightbit

func StrictlyEightbit(r io.Reader) *AustereReader

func StrictlySevenbit

func StrictlySevenbit(r io.Reader) *AustereReader

func (*AustereReader) Read

func (ar *AustereReader) Read(p []byte) (n int, err error)

Cf. [Wood99, p. 47]

type ErrUnknownCharset

type ErrUnknownCharset struct {
	Charset string
}

func (*ErrUnknownCharset) Error

func (err *ErrUnknownCharset) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL