strutil

package
v0.0.0-...-b6f29c3 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: ISC Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBase37 = 6582952005840035281

MaxBase37 Max base37 string hash for 12-rune usernames. (999999999999)

Variables

View Source
var Base16 struct {
	//Int returns an integer representation of the provided base-16 string
	Int func(string) uint64
	//String returns the base-16 string representation of the provided hexidecimal integer
	String func(uint64) string
}
View Source
var Base2 struct {
	//Int returns an integer representation of the provided base-2 string
	Int func(string) uint64
	//String returns the base-2 string representation of the provided hexidecimal integer
	String func(uint64) string
}
View Source
var Base37 struct {
	//Encode Encodes a string into its base 37 integer hash and returns the hash.  Input will be filtered appropriately.
	Encode func(string) uint64
	//Decode Decodes a string from its base 37 integer hash form back into a Go string and returns it, placing capital letters where appropriate.
	Decode func(uint64) string
}

Base37 Represents a single API access point for encoding strings to their base 37 integer hash and converting base 37 hashes back to strings.

View Source
var BaseConversion struct {
	//Int returns an integer representation of the provided string using the provided base.
	Int func(int, string) uint64
	//String returns a string encoding of the provided integer using the provided base.
	String func(int, uint64) string
}
View Source
var ChatFilter struct {
	//Pack Takes a string as input, and returns a packed bitstream as output.  It can fit any of the first 13 runes in the alphabet into 4 bits per rune, but for the rest of the alphabet it's 8 bits.
	Pack func(string) []byte
	//Unpack Takes a byte slice as input, and decodes it into a human readable chat message.
	//  Works by unpacking the bits into 2 4-bit values.  86% of the time, this is enough information for the output rune.
	//  14% of the time, it will cache this value and use the next 4 bits to help decode the rune.
	//  The first 13 runes in the charset map 1 to 1 for 13/15 possibilities within each 4 bits.
	Unpack func([]byte) string
	//Format Format a given string for use with the in-game chat systems.
	// Will replace certain symbols and auto-capitalize sentences.  Maybe more later.
	Format func(string) string
}

ChatFilter Represents a single API access point for encoding and decoding chat messages using

Functions

func CombatPrefix

func CombatPrefix(delta int) string

CombatPrefix Returns the chat prefix to colorize combat levels in right click menus and such. The color fades red as the target compares better than you, or fades green as the target compares worse than you. White indicates an equal target.

func Decipher

func Decipher(msg []byte, decipheredLength int) string

func Encipher

func Encipher(txt string) ([]byte, int)

func IPToHexidecimal

func IPToHexidecimal(s string) string

func IPToInteger

func IPToInteger(s string) (ip net.IP)

IPToInteger Converts a string representation of an IPv4 address(e.g 127.0.0.1) to a 4-byte integer, each byte containing the information from one octet.

func JagHash

func JagHash(s string) int

JagHash implements a string hashing function for file names contained in a jagball archive.

func ParseArgs

func ParseArgs(s string) []string

ParseArgs Neat command argument parsing function with support for single-quotes, ported from Java

Types

This section is empty.

Jump to

Keyboard shortcuts

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