byteconv

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 2 Imported by: 38 modules, 41 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Byteconv

Alloc-free conversions between bytes, strings and runes.

At the moment supports the following conversion:

  • []byte -> string using BytesToString()/B2S()
  • string -> []byte using StringToBytes()/S2B()
  • []byte -> []rune using AppendBytesToRunes()/AppendB2R()
  • []rune -> []byte using AppendRunesToBytes()/AppendR2B()
  • string -> []rune using AppendStringToRunes()/AppendS2R()
  • []rune -> string using AppendRunesToString()/AppendR2S()

All functions perform fast conversions using unsafe cast or buffer approach.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendB2R

func AppendB2R(dst []rune, b []byte) []rune

AppendB2R is a shorthand alias of AppendBytesToRunes().

func AppendBytesToRunes

func AppendBytesToRunes(dst []rune, p []byte) []rune

AppendBytesToRunes converts byte array to runes array.

func AppendR2B

func AppendR2B(dst []byte, r []rune) []byte

AppendR2B is a shorthand alias of AppendRunesToBytes().

func AppendR2S

func AppendR2S(buf []byte, r []rune) ([]byte, string)

AppendR2S is a shorthand alias of AppendRunesToString().

func AppendRunesToBytes

func AppendRunesToBytes(dst []byte, r []rune) []byte

AppendRunesToBytes converts runes array to bytes array.

func AppendRunesToString

func AppendRunesToString(buf []byte, r []rune) ([]byte, string)

AppendRunesToString converts runes array to string using byte buffer.

func AppendS2R

func AppendS2R(dst []rune, s string) []rune

AppendS2R is a shorthand alias of AppendStringToRunes().

func AppendStringToRunes

func AppendStringToRunes(dst []rune, s string) []rune

AppendStringToRunes converts string to runes array.

func B2S

func B2S(b []byte) string

B2S is a shorthand alias of BytesToString().

func BytesToString

func BytesToString(b []byte) string

BytesToString makes fast conversion of bytes array to string.

func S2B

func S2B(s string) []byte

S2B is a shorthand alias of StringToBytes().

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes makes fast conversion of string to bytes sequence.

Types

type SliceHeader added in v1.0.1

type SliceHeader struct {
	Data uintptr
	Len  int
	Cap  int
}

SliceHeader represents deprecated reflect.SliceHeader type.

type StringHeader added in v1.0.1

type StringHeader struct {
	Data uintptr
	Len  int
}

StringHeader represents deprecated reflect.StringHeader type.

Jump to

Keyboard shortcuts

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