Imports #
"errors"
"unicode/utf8"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/bidi"
"errors"
"unicode/utf8"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/bidi"
ErrInvalid indicates a label is invalid according to the Bidi Rule.
var ErrInvalid = *ast.CallExpr
Precomputing the ASCII values decreases running time for the ASCII fast path by about 30%.
var asciiTable [128]bidi.Properties
[2.4] In an RTL label, if an EN is present, no AN may be present, and vice versa.
const exclusiveRTL = *ast.CallExpr
const ruleInitial ruleState = iota
const ruleInvalid
const ruleLTR
const ruleLTRFinal
const ruleRTL
const ruleRTLFinal
var transitions = [...][2]ruleTransition{...}
type ruleState uint8
Transformer implements transform.Transform.
type Transformer struct {
state ruleState
hasRTL bool
seen uint16
}
type ruleTransition struct {
next ruleState
mask uint16
}
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 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 returns a Transformer that verifies that input adheres to the Bidi Rule.
func New() *Transformer
Reset implements transform.Transformer.
func (t *Transformer) Reset()
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 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 reports whether b conforms to the BiDi rule.
func Valid(b []byte) bool
ValidString reports whether s conforms to the BiDi rule.
func ValidString(s string) bool
func (t *Transformer) advance(s []byte) (n int, ok bool)
func (t *Transformer) advanceString(s string) (n int, ok bool)
func init()
func (t *Transformer) isFinal() bool
func (t *Transformer) isFinal() bool
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