Source File
transform.go
Belonging Package
vendor/golang.org/x/text/transform
package transform // import "golang.org/x/text/transform"
import (
)
ErrShortDst = errors.New("transform: short destination buffer")
ErrShortSrc = errors.New("transform: short source buffer")
ErrEndOfSpan = errors.New("transform: input and output are not identical")
errInconsistentByteCount = errors.New("transform: inconsistent byte count returned")
errShortInternal = errors.New("transform: short internal buffer")
)
Reset()
}
type SpanningTransformer interface {
Transformer
type NopResetter struct{}
func (NopResetter) () {}
transformComplete bool
}
const defaultBufSize = 4096
.transformComplete = .err != nil
continue
continue
default:
.n = 0
-= len()
= [:]
if < len() && ( == nil || == ErrShortSrc) {
continue
}
}
switch {
if > 0 || > 0 {
continue
}
case ErrShortSrc:
if len() < len(.src) {
continue
}
case nil:
if .n > 0 {
= errInconsistentByteCount
}
}
return ,
}
}
func ( *Writer) () error {
:= .src[:.n]
for {
, , := .t.Transform(.dst, , true)
if , := .w.Write(.dst[:]); != nil {
return
}
if != ErrShortDst {
return
}
= [:]
}
}
type nop struct{ NopResetter }
func (nop) (, []byte, bool) (, int, error) {
:= copy(, )
if < len() {
= ErrShortDst
}
return , ,
}
func (nop) ( []byte, bool) ( int, error) {
return len(), nil
}
type discard struct{ NopResetter }
func (discard) (, []byte, bool) (, int, error) {
return 0, len(), nil
}
Nop SpanningTransformer = nop{}
)
if == {
return .n, .p, ErrShortDst
}
if .n != 0 {
= true
continue
.fatalError(, errShortInternal)
case ErrShortSrc:
= ErrShortSrc
break
.fatalError(, errShortInternal)
break
if > {
--
continue
}
default:
.fatalError(, )
++
=
}
if ! && !utf8.FullRune() {
= ErrShortSrc
break
if !() {
if +3 > len() {
= ErrShortDst
break
}
+= copy([:], "\uFFFD")
}
++
continue
}
}
if !() {
if + > len() {
= ErrShortDst
break
}
+= copy([:], [:])
}
+=
}
return
}
:= [2 * initialBufSize]byte{}
:= [:initialBufSize:initialBufSize]
:= [initialBufSize : 2*initialBufSize]
, := 0, 0
, := 0, 0
:= 0
break
} else if == ErrShortSrc {
break
if ( == nil && == len()) ||
( != nil && != ErrShortDst && != ErrShortSrc) {
return string([:]), ,
}
if == ErrShortDst {
if == 0 {
= grow(, )
}
} else if == ErrShortSrc {
if {
return string([:]), ,
}
if == 0 {
= grow(, 0)
}
} else if != nil || == len() {
return string([:]), ,
}
}
}
func ( Transformer, , []byte) ( []byte, int, error) {
if len() == cap() {
:= len() + len() // It is okay for this to be 0.
:= make([]byte, )
= [:copy(, )]
}
return doAppend(, len(), [:cap()], )
}
func ( Transformer, int, , []byte) ( []byte, int, error) {
.Reset()
:= 0
for {
, , := .Transform([:], [:], true)
+=
+=
if != ErrShortDst {
return [:], ,
}
if == 0 {
= grow(, )
}
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |