strutil

package
v0.0.0-...-1047d84 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: ISC Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBase37 = 6582952005840035281

MaxBase37 Max username hash for 12-rune usernames.

Variables

This section is empty.

Functions

func Base37

func Base37(s string) uint64

Base37 Takes a string as input, encodes it to base37, and returns it.

func DecodeBase37

func DecodeBase37(l uint64) string

DecodeBase37 Takes a long integer for input, decodes from base37 and returns it as a string.

func FormatChatMessage

func FormatChatMessage(msg string) string

FormatChatMessage Format a given string for use with the in-game chat systems. Will replace certain symbols and auto-capitalize sentences. Maybe more later.

func ModalParse

func ModalParse(s string) []string

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

func PackChatMessage

func PackChatMessage(msg string) []byte

PackChatMessage 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.

func UnpackChatMessage

func UnpackChatMessage(data []byte) string

UnpackChatMessage 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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