Standard library / strconv

strconv.QuoteToASCII()

Returns a double-quoted Go literal with non-ASCII characters escaped, preserving the original value when unquoted. Expected stdout: '"\\u00e9"\n'.

Formal Syntax & Structure

go syntaxgo
func QuoteToASCII(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.QuoteToASCII("é"))}
Go Reference