Quote in Go

Posted by GoDoc
Public (Editable by Users)

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 IsPrint.

Go
Edit
package main

import (
	"fmt"
	"strconv"
)

func main() {
	s := strconv.Quote(`"Fran & Freddie's Diner	☺"`) // there is a tab character inside the string literal
	fmt.Println(s)
}