func (db *DbFile) Encoding() int {
	return int(db.header.DbEncoding)
}
Encoding returns the text encoding for this database
package sqlite3
import (
	"fmt"
	"io"
	"os"
	"reflect"
	"strings"
	"github.com/gonuts/binary"
)
const (
	sqlite3Magic = "SQLite format 3\x00"
	printfDebug = false
)
var (
	tblconstraints = []string{"CHECK", "FOREIGN KEY", "UNIQUE", "PRIMARY KEY"}
)
type DbFile struct {
	pager  pager
	header dbHeader
	tables []Table
	close  func() error
}
type dbHeader struct {
	Magic         [16]byte
	PageSize      uint16   
	WVersion      byte     
	RVersion      byte     
	NReserved     byte     
	MaxFraction   byte     
	MinFraction   byte     
	LeafFraction  byte     
	NFileChanges  int32    
	DbSize        int32    
	FreePage      int32    
	NFreePages    int32    
	SchemaCookie  [4]byte  
	SchemaFormat  int32    
	PageCacheSize int32    
	AutoVacuum    int32    
	DbEncoding int32
	UserVersion int32  
	IncrVacuum  int32  
	ApplicationID int32  
	XXX_reserved  [20]byte  
	VersionValid  int32     
	SqliteVersion int32     
}
func OpenFrom(f io.ReadSeeker) (*DbFile, error) {
	var db DbFile
	dec := binary.NewDecoder(f)
	dec.Order = binary.BigEndian
	err := dec.Decode(&db.header)
	if err != nil {
		return nil, err
	}
	if db.header.DbSize == 0 {
		size, err := f.Seek(0, io.SeekEnd)
		if err != nil {
			return nil, err
		}
		if _, err := f.Seek(0, io.SeekStart); err != nil {
			return nil, err
		}
		pagesz := int64(db.header.PageSize)
		npages := (size + pagesz - 1) / pagesz
		db.header.DbSize = int32(npages)
	}
	if printfDebug {
		fmt.Printf("db: %#v\n", db.header)
	}
	_, err = f.Seek(0, 0)
	if err != nil {
		return nil, err
	}
	if string(db.header.Magic[:]) != sqlite3Magic {
		return nil, fmt.Errorf(
			"sqlite: invalid file header.\ngot:  %q\nwant: %q\n",
			string(db.header.Magic[:]),
			sqlite3Magic,
		)
	}
	db.pager = newPager(f, db.PageSize(), db.NumPage())
	err = db.init()
	if err != nil {
		return nil, err
	}
	return &db, err
}
func Open(fname string) (*DbFile, error) {
	f, err := os.Open(fname)
	if err != nil {
		return nil, err
	}
	db, err := OpenFrom(f)
	if err != nil {
		f.Close()
		return nil, err
	}
	db.close = f.Close
	return db, nil
}
func (db *DbFile) Close() error {
	db.pager.Delete()
	if db.close != nil {
		return db.close()
	}
	return nil
}
func (db *DbFile) PageSize() int {
	return int(db.header.PageSize)
}
func (db *DbFile) NumPage() int {
	return int(db.header.DbSize)
}