strconv

package
v0.15.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: Apache-2.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Escape

func Escape(dst, src []byte, idx int) int

Escape copies byte slice src to dst at a given index, adding escaping any quote or control characters. It returns the index at which the copy finished.

NB: ensure that dst is large enough to store src, additional quotation runes, and any additional escape characters. as generated by Quote, to dst and returns the extended buffer.

func EscapedLength

func EscapedLength(src []byte) int

EscapedLength computes the length required for a byte slice to hold a quoted byte slice.

NB: essentially a dry-run of `Escape` that does not write characters, but instead counts total character counts for the destination byte slice.

func IsAlphaNumeric added in v0.8.0

func IsAlphaNumeric(str string) bool

IsAlphaNumeric returns true if the given string is alpha numeric.

NB: here this means that it contains only characters in [0-9A-Za-z])

func IsRuneAlphaNumeric added in v0.8.0

func IsRuneAlphaNumeric(r rune) bool

IsRuneAlphaNumeric returns true if the given rune is alpha numeric.

NB: here this means that it contains only characters in [0-9A-Za-z])

func NeedToEscape

func NeedToEscape(bb []byte) bool

NeedToEscape returns true if the byte slice contains characters that will need to be escaped when quoting the slice.

func Quote

func Quote(dst, src []byte, idx int) int

Quote copies byte slice src to dst at a given index, adding quotation runes around the src slice and escaping any quote or control characters. It returns the index at which the copy finished.

NB: ensure that dst is large enough to store src, additional quotation runes, and any additional escape characters. as generated by Quote, to dst and returns the extended buffer.

NB: based on stconv.Quote method, but instead uses indexed insertion into a predefined buffer.

func QuoteSimple

func QuoteSimple(dst, src []byte, idx int) int

QuoteSimple copies byte slice src to dst at a given index, adding quotation runes around the src slice, but does not escape any characters. It returns the index at which the copy finished.

NB: ensure that dst is large enough to store src and two other characters.

func QuotedLength

func QuotedLength(src []byte) int

QuotedLength computes the length required for a byte slice to hold a quoted byte slice.

NB: essentially a dry-run of `Quote` that does not write characters, but instead counts total character counts for the destination byte slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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