How to use strconv.QuoteToASCII() Function in Golang? Last Updated : 03 May, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a QuoteToASCII() function which is used to find a double-quoted Go string literal representing str and the returned string uses Go escape sequences (\t, \n, \xFF, \u0100) to non-ASCII characters and non-printable characters defined by IsPrint. To access QuoteToASCII() function you need to import strconv Package in your program with the help of import keyword. Syntax: func QuoteToASCII(str string) string Parameter: This function takes one parameter of string type, i.e., str. Return value: This function returns a double-quoted Go string literal which represents str. Let us discuss this concept with the help of the given examples: Example 1: // Golang program to illustrate // strconv.QuoteToASCII() Function package main import ( "fmt" "strconv" ) func main() { // Finding a double-quoted Go // string literal representing str // Using QuoteToASCII() function str := strconv.QuoteToASCII(`"♥ Welcome GeeksforGeeks ♥ "`) fmt.Println (str) } Output: "\"\u2665 Welcome GeeksforGeeks \u2665 \"" Example 2: // Golang program to illustrate // strconv.QuoteToASCII() Function package main import ( "fmt" "strconv" ) func main() { // Finding a double-quoted Go // string literal representing rune // Using QuoteToASCII() function val1 := strconv.QuoteToASCII(`"I like Δ "`) fmt.Println("Result 1: ", val1) fmt.Println("Length 1: ", len(val1)) val2 := strconv.QuoteToASCII(`"I love ♦"`) fmt.Println("Result 2: ", val2) fmt.Println("Length 2: ", len(val2)) } Output: Result 1: "\"I like \u0394\t\"" Length 1: 21 Result 2: "\"I love \u2666\"" Length 2: 23 Comment More infoAdvertise with us Next Article How to use strconv.QuoteRuneToGraphic() Function in Golang? A ankita_saini Follow Improve Article Tags : Go Language ASCII Golang-strconv Similar Reads How to use strconv.QuoteRuneToASCII() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a QuoteRuneToASCII() function which is used to find a single-quoted Go string literal representing rune and the returned string uses Go escap 2 min read How to use strconv.Quote() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a Quote() function which is used to find a double-quoted Go string literal representing str and the returned string uses Go escape sequences 2 min read How to use strconv.QuoteToGraphic() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a QuoteToGraphic() function which is used to find a double-quoted Go string literal representing str and the returned string leaves Unicode g 2 min read How to use strconv.QuoteRune() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a QuoteRune() function which is used to find a single-quoted Go string literal representing rune and the returned string uses Go escape seque 2 min read How to use strconv.QuoteRuneToGraphic() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides a QuoteRuneToGraphic() function which is used to find a single-quoted Go character literal representing the rune. If the rune is not a Unicod 2 min read How to use strconv.Itoa() Function in Golang? Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides an Itoa() function which is equivalent to FormatInt(int64(x), 10). Or in other words, Itoa() function returns the string representation of x 2 min read Like