Documentation
¶
Overview ¶
Package ascii provides support for ASCII strings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Quoted ¶
Quoted returns a a double-quoted string safely escaped with Go syntax. Non-ASCII characters are converted to Unicode escape sequences.
e.g. ToAscii("Θ") returns "\"\u0398\""
func ToASCII ¶ added in v0.3.1
ToASCII returns the string with non-ascii characters escaped. This converts any non-ASCII characters to their respective Unicode escape sequence (in ASCII characters).
e.g. ToAscii("Θ") returns "\u0398"
func ToBinary ¶ added in v0.3.1
func ToBinary(v interface{}) string
ToBinary returns a value (int, float, bool, nil) in hexadecimal notation. Any nil value is returned as zero. Rune and byte types are already uint32 and uint8, respectively, by definition. Other types return 'NaN'
exponents are powers of two
e.g. ToBinary() returns -0x1.23abcp+20
func ToHex ¶ added in v0.3.1
func ToHex(v interface{}) string
ToHex returns a value (int, float, bool, nil) in hexadecimal notation. Any nil value is returned as zero. Rune and byte types are already uint32 and uint8, respectively, by definition. Other types return 'NaN'
exponents are powers of two
e.g. ToHex() returns -0x1.23abcp+20
Use of lowercase is the convention based on minimal research: https://twitter.com/sindresorhus/status/926521127869988864 https://meh.com/forum/topics/capital-crimes-part-1--shout-shout-let-it-all-out https://en.wikipedia.org/wiki/Hexadecimal
In addition:
echo "hexdump uses lowercase" |hexdump 0000000 68 65 78 64 75 6d 70 20 75 73 65 73 20 6c 6f 77 0000010 65 72 63 61 73 65 0a 0000017
and
echo "xxd uses lowercase" |xxd 00000000: 7878 6420 7573 6573 206c 6f77 6572 6361 xxd uses lowerca 00000010: 7365 0a se.
Types ¶
This section is empty.