Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source pure

Package text holds the small string helpers shared by the GnoRadio realms.

Overview

Package text holds the small string helpers shared by the GnoRadio realms.

Functions 13

func Atoi

1func Atoi(s string) int
source

Atoi and Atoi64 read a stored decimal; anything else is 0.

func Digits

1func Digits(s string) bool
source

Digits reports whether s is a non-empty run of ASCII digits.

func Flag

1func Flag(b bool) string
source

Flag is a stored boolean: "1" or "".

func GNOT

1func GNOT(u int64) string
source

GNOT formats ugnot as GNOT with up to 6 decimals.

func HTTPS

1func HTTPS(s string, max int) bool
source

HTTPS accepts an https link of URL-safe characters, 11 to max bytes.

func Itoa

1func Itoa(n int) string
source

Itoa and Itoa64 skip strconv for the frequent zero: every conversion costs gas.

func MustAtoi

1func MustAtoi(s string) int
source

MustAtoi and MustAtoi64 read a stored number on a money or authority path: a corrupt record panics (the transaction reverts) instead of reading as 0.

func Str

1func Str(s string) string
source

Str quotes a value as a JSON string without escaping. Use it only for values whose validator already refuses `"`, `\` and control characters (Valid text, validated URLs, hashes, addresses, constants): escaping costs about 1M gas per field in the VM.

func URLChars

1func URLChars(s string) bool
source

URLChars accepts only URL-safe characters (A-Z a-z 0-9 - . _ ~ : / ? # = & % + @): safe in markdown link destinations and JSON as is.

func Valid

1func Valid(s string, min, max int) bool
source

Valid accepts min..max runes of letters (any script), digits, spaces and . , ' - ! ? : / &. Markdown, HTML and JSON specials are refused, so the text is safe in markdown and JSON as is (SVG still escapes '&'). Fullwidth and mathematical letters (which dodge word filters) and the blank Hangul fillers are refused too.

Imports 3

  • strconv stdlib
  • strings stdlib
  • unicode stdlib

Source Files 2