decode

package
v0.0.0-...-5c361fe Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Codecs = []struct {
	Name      string
	CodecCons codecConstructor
}{
	{
		b16name,
		codecConstructor(NewB16CodecC),
	},
	{
		b32name,
		codecConstructor(NewB32CodecC),
	},
	{
		b64name,
		codecConstructor(NewB64CodecC),
	},
	{
		urlname,
		codecConstructor(NewURLCodecC),
	},
	{
		gzipname,
		codecConstructor(NewGzipCodecC),
	},
}

Functions

func IsPrint

func IsPrint(decoded string) bool

IsPrint checks if a decoded string is a valid utf string

Types

type Base16

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

Base16 takes a decoder and an input string

func (*Base16) Check

func (b *Base16) Check() (acceptability float64)

Check returns the percentage of valid b16 characters in the input string

func (*Base16) Decode

func (b *Base16) Decode() (output string)

Decode a valid b16 string

func (*Base16) Encode

func (b *Base16) Encode() (output string)

Encode a string into b16

func (*Base16) Name

func (b *Base16) Name() string

Name returns the name of the codec

type Base32

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

Base32 takes a decoder and an input string

func (*Base32) Check

func (b *Base32) Check() (acceptability float64)

Check returns the percentage of valid b32 characters in the input string

func (*Base32) Decode

func (b *Base32) Decode() (output string)

Decode a valid b32 string

func (*Base32) Encode

func (b *Base32) Encode() (output string)

Encode a string into b32

func (*Base32) Name

func (b *Base32) Name() string

Name returns the name of the codec

type Base64

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

Base64 takes a decoder and an input string

func (*Base64) Check

func (b *Base64) Check() (acceptability float64)

Check returns the percentage of valid b16 characters in the input string

func (*Base64) Decode

func (b *Base64) Decode() (output string)

Decode a valid b64 string

func (*Base64) Encode

func (b *Base64) Encode() (output string)

Encode a string into b64 with StdEncodig set

func (*Base64) Name

func (b *Base64) Name() string

Name returns the name of the codec

type Checker

type Checker interface {
	Check() (acceptability float64)
}

Checker returns a metric to determine how likely it is for the given string to be a valid value for the specified Checker Type. The likelihood always ranges between 0 and 1

type CodecC

type CodecC interface {
	Decoder
	Encoder
	Checker
	Name() string
}

CodecC creates an interface of interfaces usable by other codecs

func NewB16CodecC

func NewB16CodecC(in string) CodecC

NewB16CodecC state machine to smartly decode a string with invalid chars nolint: gocyclo

func NewB32CodecC

func NewB32CodecC(in string) CodecC

NewB32CodecC state machine to smartly decode a string with invalid chars nolint: gocyclo

func NewB64CodecC

func NewB64CodecC(in string) CodecC

NewB64CodecC state machine to smartly decode a string with invalid chars and different variants nolint: gocyclo

func NewGzipCodecC

func NewGzipCodecC(in string) CodecC

NewGzipCodecC initialize a new gzip decoder object

func NewURLCodecC

func NewURLCodecC(in string) CodecC

NewURLCodecC initialize a new URL object

func SmartDecode

func SmartDecode(input string) (c CodecC)

SmartDecode loops through the available CodecCs and determine which one is the best one to use

type Decoder

type Decoder interface {
	Decode() (output string)
}

Decoder decodes the string and returns a decoded value that tries to skip invalid input and to decode as much as possible. Returns if the decoded string can be printed as valid unicode.

type Encoder

type Encoder interface {
	Encode() (output string)
}

Encoder encodes the string

type Pos

type Pos int

Pos is an integer that define a position inside a string

type URL

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

URL takes an input string

func (*URL) Check

func (b *URL) Check() (acceptability float64)

Check returns the percentage of valid url characters in the input string

func (*URL) Decode

func (b *URL) Decode() (output string)

Decode a valid url encoded string

func (*URL) Encode

func (b *URL) Encode() (output string)

Encode a string to url encode

func (*URL) Name

func (b *URL) Name() string

Name returns the name of the codec

Jump to

Keyboard shortcuts

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