quotedprintable

package
v1.21.8 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

パッケージquotedprintableは、RFC 2045で指定されているquoted-printableエンコーディングを実装します。

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Readerは、quoted-printableデコーダーです。

func NewReader

func NewReader(r io.Reader) *Reader

NewReaderは、rからデコードするquoted-printableリーダーを返します。

Example
package main

import (
	"github.com/shogo82148/std/fmt"
	"github.com/shogo82148/std/io"
	"github.com/shogo82148/std/mime/quotedprintable"
	"github.com/shogo82148/std/strings"
)

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

Hello, Gophers! <nil>
invalid escape: <b style="font-size: 200%">hello</b> <nil>
Hello, Gophers! This symbol will be unescaped: = and this will be written in one line. <nil>

func (*Reader) Read

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

Readは、基礎となるリーダーからquoted-printableデータを読み取り、デコードします。

type Writer

type Writer struct {
	// バイナリモードでは、ライターの入力を純粋なバイナリとして扱い、
	// 行末のバイトをバイナリデータとして処理します。
	Binary bool
	// contains filtered or unexported fields
}

Writerは、io.WriteCloserを実装するquoted-printableライターです。

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriterは、wに書き込む新しいWriterを返します。

Example
package main

import (
	"github.com/shogo82148/std/mime/quotedprintable"
	"github.com/shogo82148/std/os"
)

func main() {
	w := quotedprintable.NewWriter(os.Stdout)
	w.Write([]byte("These symbols will be escaped: = \t"))
	w.Close()

}
Output:

These symbols will be escaped: =3D =09

func (*Writer) Close

func (w *Writer) Close() error

CloseはWriterを閉じ、未書き込みのデータを基礎となるio.Writerにフラッシュしますが、 基礎となるio.Writerを閉じるわけではありません。

func (*Writer) Write

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

Writeは、pをquoted-printableエンコーディングでエンコードし、それを 基礎となるio.Writerに書き込みます。行の長さは76文字に制限されます。 エンコードされたバイトは、Writerが閉じられるまで必ずしもフラッシュされません。

Jump to

Keyboard shortcuts

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