Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrShortDst means that the destination buffer was too short to // receive all of the transformed bytes. ErrShortDst = errors.New("transform: short destination buffer") // ErrShortSrc means that the source buffer has insufficient data to // complete the transformation. ErrShortSrc = errors.New("transform: short source buffer") )
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct { transform.Transformer // contains filtered or unexported fields }
A Decoder converts bytes to UTF-8. It implements transform.Transformer.
Transforming source bytes that are not of that encoding will not result in an error per se. Each byte that cannot be transcoded will be represented in the output by the UTF-8 encoding of '\uFFFD', the replacement rune.
func NewDecoder ¶
NewDecoder returns an x/text Decoder for the specified text encoding. The Decoder converts a character encoding into utf-8 bytes. If a BOM is found it will be converted into an utf-8 BOM, you can use github.com/dimchansky/utfbom to strip the BOM.
The "none" or "" encoding will pass through bytes unchecked. Use the utf-8 encoding if you want invalid bytes replaced using the unicode replacement character.
Detection of utf-16 endianness using the BOM is not currently provided due to the tail input plugins requirement to be able to start at the middle or end of the file.
func (*Decoder) Bytes ¶ added in v1.15.2
Bytes converts the given encoded bytes to UTF-8. It returns the converted bytes or nil, err if any error occurred.
type Reader ¶ added in v1.15.2
type Reader struct {
// contains filtered or unexported fields
}
Reader wraps another io.Reader by transforming the bytes read.