func (erw *Encoder) LimitRead(n int64) {
	erw.r = io.LimitReader(erw.rw, n)
}
LimitRead limits the read to n bytes
package binary
import (
	"encoding/binary"
	"fmt"
	"io"
	"io/ioutil"
	"regexp"
	"golang.org/x/text/encoding"
)
const maxTextSize = 100000
type Encoder struct {
	rw          io.ReadWriter     
	r           io.Reader         
	sbuf        [8]byte           
	endianness  binary.ByteOrder  
	charset     encoding.Encoding
	charEncoder *encoding.Encoder
	charDecoder *encoding.Decoder
	err         error
}
func NewEncoder(rw io.ReadWriter, endianness binary.ByteOrder) Encoder {
	encoder := Encoder{rw: rw, r: rw, endianness: endianness}
	return encoder
}
func NewEncoderCharset(rw io.ReadWriter, endianness binary.ByteOrder,
	charset encoding.Encoding) (e Encoder, err error) {
	encoder := Encoder{rw: rw, r: rw, endianness: endianness, charset: charset}
	err = encoder.SetCharset(charset)
	return encoder, err
}
func (erw *Encoder) SetEndianness(endianness binary.ByteOrder) {
	erw.endianness = endianness
}
func (erw Encoder) Endianness() binary.ByteOrder {
	return erw.endianness
}
func (erw *Encoder) SetCharset(c encoding.Encoding) error {
	erw.charset = c
	erw.charEncoder, erw.charDecoder = c.NewEncoder(), c.NewDecoder()
	return erw.err
}
func (erw *Encoder) Write(b []byte) (cnt int, err error) {
	if erw.err != nil {
		return
	}
	cnt, erw.err = erw.rw.Write(b[:])
	return cnt, erw.err
}
func (erw *Encoder) Read(data []byte) (cnt int, err error) {
	if erw.err != nil {
		return
	}
	cnt, erw.err = io.ReadFull(erw.r, data[:])
	return cnt, erw.err
}