func Skip(rd io.Reader) (*Reader, Encoding)
Skip creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary. It also returns the encoding detected by the BOM. If the detected encoding is not needed, you can call the SkipOnly function.
Encoding is type alias for detected UTF encoding.
type Encoding int
Constants to identify detected UTF encodings.
const ( // Unknown encoding, returned when no BOM was detected Unknown Encoding = iota // UTF8, BOM bytes: EF BB BF UTF8 // UTF-16, big-endian, BOM bytes: FE FF UTF16BigEndian // UTF-16, little-endian, BOM bytes: FF FE UTF16LittleEndian // UTF-32, big-endian, BOM bytes: 00 00 FE FF UTF32BigEndian // UTF-32, little-endian, BOM bytes: FF FE 00 00 UTF32LittleEndian )
func (e Encoding) String() string
String returns a user-friendly string representation of the encoding. Satisfies fmt.Stringer interface.
Reader implements automatic BOM (Unicode Byte Order Mark) checking and removing as necessary for an io.Reader object.
type Reader struct {
// contains filtered or unexported fields
}
func SkipOnly(rd io.Reader) *Reader
SkipOnly creates Reader which automatically detects BOM (Unicode Byte Order Mark) and removes it as necessary.
func (r *Reader) Read(p []byte) (n int, err error)
Read is an implementation of io.Reader interface. The bytes are taken from the underlying Reader, but it checks for BOMs, removing them as necessary.