Standard library / strconv

strconv.QuoteToGraphic()

Returns a double-quoted Go literal retaining Unicode graphic runes where possible, escaping other characters as needed. Expected stdout: '"é\\n"\n'.

Formal Syntax & Structure

go syntaxgo
func QuoteToGraphic(s string) string

Parameters & Attributes

NameTypeDescription
sstringInput text to parse, inspect or quote.

Return Value

string

Encoded representation.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strconv")
func main() {  fmt.Println(strconv.QuoteToGraphic("é\n"))}
Go Reference