stringprep

package
v0.0.0-...-76db0e1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2016 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package stringprep implements Stringprep as described in RFC 3454, including the Nameprep profile.

This package is in beta and is still being written and tested.

Index

Constants

View Source
const (
	Unassigned valueType = iota
	Map
	Prohibited
	Delete
)
View Source
const (
	NFKC                = 1
	BIDI                = 2
	MAP_TABLE           = 3
	UNASSIGNED_TABLE    = 4
	PROHIBIT_TABLE      = 5
	BIDI_PROHIBIT_TABLE = 6
	BIDI_RAL_TABLE      = 7
	BIDI_L_TABLE        = 8
)

Steps in a stringprep profile.

View Source
const MaxMapChars = 4

MaxMapChars is the largest number of runes/bytes a mapping will take up.

Variables

View Source
var (
	// Profiles is a map of the various stringprep profiles we implement.
	Profiles = map[string]Profile{
		"nameprep": nameprepProfile,
	}
)
View Source
var Tables = map[string]Table{
	"A1":  _A1,
	"B1":  _B1,
	"B2":  _B2,
	"B3":  _B3,
	"C11": _C11,
	"C12": _C12,
	"C21": _C21,
	"C22": _C22,
	"C3":  _C3,
	"C4":  _C4,
	"C5":  _C5,
	"C6":  _C6,
	"C7":  _C7,
	"C8":  _C8,
	"C9":  _C9,
	"D1":  _D1,
	"D2":  _D2,
}

Tables defines the various unicode tables.

Functions

func Nameprep

func Nameprep(input string) (string, error)

Nameprep performs the nameprep stringprep conversion on a string and returns it.

func PrepareRunes

func PrepareRunes(profile Profile, input []rune) ([]rune, error)

PrepareRunes prepares the input rune array according to the stringprep profile, and returns the results as a rune array.

Types

type Iter

type Iter struct{}

An Iter iterates over a string or byte slice, while preparing it with a given Profile.

func (*Iter) Done

func (i *Iter) Done() bool

Done returns true if there is no more input to process.

func (*Iter) Next

func (i *Iter) Next(buf []byte) int

Next writes p(i.input[i.Pos():n]...) to buffer buf, where n is the largest boundary of i.input such that the result fits in buf. It returns the number of bytes written to buf. len(buf) should be at least MaxSegmentSize. Done must be false before calling Next.

func (*Iter) Pos

func (i *Iter) Pos() int

Pos returns the byte position at which the next call to Next will commence processing.

func (*Iter) SetInput

func (i *Iter) SetInput(p *Profile, src []byte)

SetInput initializes i to iterate over src after normalizing it to Profile p.

func (*Iter) SetInputString

func (i *Iter) SetInputString(p *Profile, src string)

SetInputString initializes i to iterate over src after normalizing it to Profile p.

type Profile

type Profile []ProfileElement

type ProfileElement

type ProfileElement struct {
	Step  int // see Step const's
	Table Table
}

type Table

type Table []TableElement

type TableElement

type TableElement struct {
	Lo  rune
	Hi  rune
	Map d // can be empty
}

Jump to

Keyboard shortcuts

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