bidirule

Imports

Imports #

"errors"
"unicode/utf8"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/bidi"

Constants & Variables

ErrInvalid var #

ErrInvalid indicates a label is invalid according to the Bidi Rule.

var ErrInvalid = *ast.CallExpr

asciiTable var #

Precomputing the ASCII values decreases running time for the ASCII fast path by about 30%.

var asciiTable [128]bidi.Properties

exclusiveRTL const #

[2.4] In an RTL label, if an EN is present, no AN may be present, and vice versa.

const exclusiveRTL = *ast.CallExpr

ruleInitial const #

const ruleInitial ruleState = iota

ruleInvalid const #

const ruleInvalid

ruleLTR const #

const ruleLTR

ruleLTRFinal const #

const ruleLTRFinal

ruleRTL const #

const ruleRTL

ruleRTLFinal const #

const ruleRTLFinal

transitions var #

var transitions = [...][2]ruleTransition{...}

Type Aliases

ruleState type #

type ruleState uint8

Structs

Transformer struct #

Transformer implements transform.Transform.

type Transformer struct {
state ruleState
hasRTL bool
seen uint16
}

ruleTransition struct #

type ruleTransition struct {
next ruleState
mask uint16
}

Functions

Direction function #

Direction reports the direction of the given label as defined by RFC 5893. The Bidi Rule does not have to be applied to labels of the category LeftToRight.

func Direction(b []byte) bidi.Direction

DirectionString function #

DirectionString reports the direction of the given label as defined by RFC 5893. The Bidi Rule does not have to be applied to labels of the category LeftToRight.

func DirectionString(s string) bidi.Direction

New function #

New returns a Transformer that verifies that input adheres to the Bidi Rule.

func New() *Transformer

Reset method #

Reset implements transform.Transformer.

func (t *Transformer) Reset()

Span method #

Span returns the first n bytes of src that conform to the Bidi rule.

func (t *Transformer) Span(src []byte, atEOF bool) (n int, err error)

Transform method #

Transform implements transform.Transformer. This Transformer has state and needs to be reset between uses.

func (t *Transformer) Transform(dst []byte, src []byte, atEOF bool) (nDst int, nSrc int, err error)

Valid function #

Valid reports whether b conforms to the BiDi rule.

func Valid(b []byte) bool

ValidString function #

ValidString reports whether s conforms to the BiDi rule.

func ValidString(s string) bool

advance method #

func (t *Transformer) advance(s []byte) (n int, ok bool)

advanceString method #

func (t *Transformer) advanceString(s string) (n int, ok bool)

init function #

func init()

isFinal method #

func (t *Transformer) isFinal() bool

isFinal method #

func (t *Transformer) isFinal() bool

isRTL method #

A rule can only be violated for "Bidi Domain names", meaning if one of the following categories has been observed.

func (t *Transformer) isRTL() bool

Generated with Arrow