func (r *Reader) Read(p []byte) (n int, err error) {
	if len(p) == 0 {
		return 0, nil
	}
	if r.buf == nil {
		if r.err != nil {
			return 0, r.readErr()
		}
		return r.rd.Read(p)
	}
	n = copy(p, r.buf)
	r.buf = nilIfEmpty(r.buf[n:])
	return n, nil
}
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.
package utfbom
import (
	"errors"
	"io"
)
type Encoding int
const (
	Unknown Encoding = iota
	UTF8
	UTF16BigEndian
	UTF16LittleEndian
	UTF32BigEndian
	UTF32LittleEndian
)
func (e Encoding) String() string {
	switch e {
	case UTF8:
		return "UTF8"
	case UTF16BigEndian:
		return "UTF16BigEndian"
	case UTF16LittleEndian:
		return "UTF16LittleEndian"
	case UTF32BigEndian:
		return "UTF32BigEndian"
	case UTF32LittleEndian:
		return "UTF32LittleEndian"
	default:
		return "Unknown"
	}
}
const maxConsecutiveEmptyReads = 100
func Skip(rd io.Reader) (*Reader, Encoding) {
	b, ok := rd.(*Reader)
	if ok {
		return b, Unknown
	}
	enc, left, err := detectUtf(rd)
	return &Reader{
		rd:  rd,
		buf: left,
		err: err,
	}, enc
}
func SkipOnly(rd io.Reader) *Reader {
	r, _ := Skip(rd)
	return r
}
type Reader struct {
	rd  io.Reader  
	buf []byte     
	err error      
}