encoding

package module
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IDToRef

func IDToRef(id uint, prefix string, length int, refChars, refPaddingChars string) (string, error)

IDToRef convert defined ID to reference

func RefToID

func RefToID(ref, prefix string, refChars, refPaddingChars string) (uint64, error)

RefToID convert defined reference to id

func String2Uint

func String2Uint(s string, chars, paddingChars string) (n uint64, err error)

String2Uint is the revert of Uint2String

It returns negative result in 2 cases:
- s contains character not exist in chars
- the result is bigger than max int64 (integer overflow happen)

func Uint2String

func Uint2String(number uint64, chars, paddingChars string, length int) (s string, err error)

Uint2String converts a number to a string using characters from chars.

Validation:

  • `length` must > 0
  • length of `chars` must >= 10
  • `paddingChars` must not be empty
  • `chars` & `paddingChars` must not overlap

If length of the result < required length, the result will be left padded with random characters from `paddingChars`.

Types

This section is empty.

Jump to

Keyboard shortcuts

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