encode

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromUTF8To

func FromUTF8To(e detect.CharEncoding, txt io.Reader) (io.Reader, error)

FromUTF8To returns encoded text from UTF-8 text

Example
package main

import (
	"bytes"
	"fmt"
	"io"
	"strings"

	"github.com/spiegel-im-spiegel/text/detect"
	"github.com/spiegel-im-spiegel/text/encode"
)

func main() {
	utf8Text := "こんにちは,世界\n"
	res, err := encode.FromUTF8To(detect.ISO2022JP, strings.NewReader(utf8Text))
	if err != nil {
		fmt.Println(err)
		return
	}
	buf := &bytes.Buffer{}
	if _, err := io.Copy(buf, res); err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(buf.Bytes())
}
Output:

[27 36 66 36 51 36 115 36 75 36 65 36 79 33 36 64 36 51 38 27 40 66 10]

Types

This section is empty.

Jump to

Keyboard shortcuts

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