util

package
v0.0.0-...-8b1d50a Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncodingISO8859 byte = iota
	EncodingUTF16BOM
	EncodingUTF16
	EncodingUTF8
)

Variables

This section is empty.

Functions

func BytesToInt

func BytesToInt(gBytes []byte) uint32

Converts given bytes into integer

func BytesToIntSynchsafe

func BytesToIntSynchsafe(gBytes []byte) uint32

Decodes given integer bytes into integer, ignores the first bit of every given byte in binary form

func DecodeText

func DecodeText(fContents []byte) string

Decodes the given frame`s contents

func GetBit

func GetBit(b byte, bitN int) bool

Tells if bit is set in given byte, if bitN <= 0 - always returns false

func GetKey

func GetKey(mp map[int]string, givenValue string) int

Returns found key (int) in provided map by value (string); If key does not exist in map - returns -1

func InASCII

func InASCII(chars string) bool

Checks if given characters are in ASCII range

func IntToBytes

func IntToBytes(gInt uint32) []byte

Simply converts given uint32 into synch unsafe bytes

func IntToBytesSynchsafe

func IntToBytesSynchsafe(gInt uint32) []byte

The exact opposite of what `BytesToIntSynchsafe` does Finally understood with the help of: https://github.com/bogem/id3v2/blob/master/size.go , thank you very much !

func Read

func Read(r io.Reader, n uint64) ([]byte, error)

Shortcut function to read n bytes from reader. The general idea peeked from here: https://github.com/dhowden/tag/blob/master/util.go

func ReadToString

func ReadToString(r io.Reader, n uint64) (string, error)

Reads from rs and conversts read []byte into string, ignoring all non-printable or invalid characters.

func SetBit

func SetBit(b byte, bitN int) byte

Sets bit to 1 in provided byte, if bitN <= 0 returns original b without modifications. bitN is the position of the bit FROM THE LAST RIGHT one! ie: byte := 0 // 00000000 newbyte := SetBit(byte, 1) // 1 // 00000001

func ToStringLossy

func ToStringLossy(gBytes []byte) string

Converts given bytes into string, ignoring the first 31 non-printable ASCII characters. (LOSSY, if given bytes contain some nasty ones)

func WriteToExtent

func WriteToExtent(wr io.Writer, data []byte, lenNeeded int) error

Writes data to wr, if len(data) is less than lenNeeded - adds null bytes until written lenNeeded bytes

Types

This section is empty.

Jump to

Keyboard shortcuts

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