detect

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: 10 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CharEncoding

type CharEncoding int

CharEncoding is type of character encoding

const (
	Unknown   CharEncoding = iota //Unknown is unknown character encoding
	UTF8                          //UTF8 is UTF-8 encoding
	ISO8859L1                     //ISO8859L1 is ISO-8859-1 (Latin-1) encoding
	ShiftJIS                      //ShiftJIS is Shift-JIS encoding
	EUCJP                         //EUCJP is EUC-JP encoding
	ISO2022JP                     //ISO2022JP is ISO-2022-JP encoding
	EUCKR                         //EUCKR is EUC-KR encoding
	GB18030                       //GB18030 is GB-18030 encoding
	Big5                          //Big5 is Big5 encoding
)

func Encoding

func Encoding(txt io.Reader, lang string) CharEncoding

Encoding returns character encoding of text

func EncodingBest

func EncodingBest(txt io.Reader) CharEncoding

EncodingBest returns character encoding of text (best selection)

Example
package main

import (
	"bytes"
	"fmt"

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

func main() {
	e := detect.EncodingBest(bytes.NewBufferString("Hello World"))
	fmt.Println(e)
}
Output:

ISO-8859-1

func EncodingJa

func EncodingJa(txt io.Reader) CharEncoding

EncodingJa returns character encoding of text (Japanese only)

Example
package main

import (
	"bytes"
	"fmt"

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

func main() {
	e := detect.EncodingJa(bytes.NewBufferString("こんにちは,世界"))
	fmt.Println(e)
}
Output:

UTF-8

func (CharEncoding) GetEncoding added in v0.3.0

func (e CharEncoding) GetEncoding() encoding.Encoding

GetEncoding returns Encoding instance

func (CharEncoding) String

func (e CharEncoding) String() string

Jump to

Keyboard shortcuts

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