Expand description
Package strconv implements conversions to and from string representations of basic data types.
§String Conversions
Quote and QuoteToASCII convert strings to quoted Go string literals. The latter guarantees that the result is an ASCII string, by escaping any non-ASCII Unicode with \u:
use ggstd::strconv;
let q = strconv::quote("Hello, 世界");
let q = strconv::quote_to_ascii("Hello, 世界");Functions§
- append_
quote - append_quote appends a double-quoted Go string literal representing s, as generated by Quote, to dst and returns the extended buffer.
- append_
quote_ to_ ascii - append_quote_to_ascii appends a double-quoted Go string literal representing s, as generated by quote_to_ascii, to dst and returns the extended buffer.
- append_
quote_ to_ graphic - append_quote_to_graphic appends a double-quoted Go string literal representing s, as generated by quote_to_graphic, to dst and returns the extended buffer.
- is_
graphic - is_graphic reports whether the rune is defined as a Graphic by Unicode. Such characters include letters, marks, numbers, punctuation, symbols, and spaces, from categories L, M, N, P, S, and Zs.
- is_
print - is_print reports whether the rune is defined as printable by Go, with the same definition as unicode.is_print: letters, numbers, punctuation, symbols and ASCII space.
- quote
- quote returns a double-quoted Go string literal representing s. The returned string uses Go escape sequences (\t, \n, \xFF, \u0100) for control characters and non-printable characters as defined by is_print.
- quote_
bytes_ string - quote_bytes_string is similar to Quote, but takes slice of bytes instead of a string. This is useful in cases when replacing Go Quote function when the Go string contains arbitrary data (in Go strings can contain arbitrary data, in Rust they cannot).
- quote_
to_ ascii - quote_to_ascii returns a double-quoted Go string literal representing s. The returned string uses Go escape sequences (\t, \n, \xFF, \u0100) for non-ASCII characters and non-printable characters as defined by is_print.
- quote_
to_ graphic - quote_to_graphic returns a double-quoted Go string literal representing s. The returned string leaves Unicode graphic characters, as defined by is_graphic, unchanged and uses Go escape sequences (\t, \n, \xFF, \u0100) for non-graphic characters.