encodedbytes

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Copyright 2013 Michael Yang. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright 2013 Michael Yang. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright 2013 Michael Yang. All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	BytesPerInt     = 4
	SynchByteLength = 7
	NormByteLength  = 8
	NativeEncoding  = 3
)

Variables

View Source
var (
	EncodingMap = [...]Encoding{
		{Name: "ISO-8859-1", NullLength: 1},
		{Name: "UTF-16", NullLength: 2},
		{Name: "UTF-16BE", NullLength: 2},
		{Name: "UTF-8", NullLength: 1},
	}
	Decoders = make([]*encoding.Decoder, len(EncodingMap))
	Encoders = make([]*encoding.Encoder, len(EncodingMap))
)

Functions

func ByteInt

func ByteInt(buf []byte, base uint) (i uint32, err error)

Form an integer from concatenated bits

func EncodedDiff

func EncodedDiff(newEncoding byte, newString string, oldEncoding byte, oldString string) (int, error)

func EncodingForIndex

func EncodingForIndex(b byte) string

func EncodingNullLengthForIndex

func EncodingNullLengthForIndex(b byte) int

func IndexForEncoding

func IndexForEncoding(e string) byte

func IntBytes

func IntBytes(n uint32, base uint) []byte

Form a byte slice from an integer

func NormBytes

func NormBytes(n uint32) []byte

func NormInt

func NormInt(buf []byte) (i uint32, err error)

func SynchBytes

func SynchBytes(n uint32) []byte

func SynchInt

func SynchInt(buf []byte) (i uint32, err error)

Types

type Encoding

type Encoding struct {
	Name       string
	NullLength int
}

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader is a helper for Reading frame bytes

func NewReader

func NewReader(b []byte) *Reader

func (*Reader) Read

func (r *Reader) Read(b []byte) (n int, err error)

func (*Reader) ReadByte

func (r *Reader) ReadByte() (b byte, err error)

func (*Reader) ReadNullTermString

func (r *Reader) ReadNullTermString(encoding byte) (string, error)

Read a null terminated string of specified encoding

func (*Reader) ReadNumBytes

func (r *Reader) ReadNumBytes(n int) ([]byte, error)

func (*Reader) ReadNumBytesString

func (r *Reader) ReadNumBytesString(n int) (string, error)

Read a number of bytes and cast to a string

func (*Reader) ReadRest

func (r *Reader) ReadRest() ([]byte, error)

Read until the end of the data

func (*Reader) ReadRestString

func (r *Reader) ReadRestString(encoding byte) (string, error)

Read until the end of the data and cast to a string

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer is a helper for writing frame bytes

func NewWriter

func NewWriter(b []byte) *Writer

func (*Writer) Write

func (w *Writer) Write(b []byte) (n int, err error)

func (*Writer) WriteByte

func (w *Writer) WriteByte(b byte) (err error)

func (*Writer) WriteNullTermString

func (w *Writer) WriteNullTermString(s string, encoding byte) (err error)

func (*Writer) WriteString

func (w *Writer) WriteString(s string, encoding byte) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL