Golang strconv.AppendQuoteRuneToASCII() function is “used to append a single-quoted character literal representing the rune, as generated by QuoteRuneToASCII, to dst and returns the extended buffer”.
Syntax
func AppendQuoteRuneToASCII(dst []byte, x rune) []byte
Parameters
- dst: A byte array (or byte slices) in which we must append the single-quoted character literal.
- r: Rune character to be appended.
Return Value
The return type of the AppendQuoteRuneToASCII() function is a []byte, and it returns the extended buffer after appending the single-quoted character.
Example 1
package main
import (
"fmt"
"strconv"
)
func main() {
// A slice of bytes
s := []byte("ASCII quote: ")
// A rune
r := '⌘'
// Convert and append the rune to the byte slice
s = strconv.AppendQuoteRuneToASCII(s, r)
// Convert the byte slice back to a string and print it
fmt.Println(string(s))
}
Output
ASCII quote: '\u2318'
Example 2
package main
import (
"fmt"
"strconv"
)
func main() {
y := []byte("QuoteRuneToASCII_Test:")
fmt.Println("Before appending...")
fmt.Println("y:", string(y))
fmt.Println("Length(y): ", len(y))
// Appending characters & various emojis
y = strconv.AppendQuoteRuneToASCII(y, 98)
y = strconv.AppendQuoteRuneToASCII(y, '🍎')
y = strconv.AppendQuoteRuneToASCII(y, '🍌')
y = strconv.AppendQuoteRuneToASCII(y, '🍒')
fmt.Println("After appending...")
fmt.Println("y:", string(y))
fmt.Println("Length(y): ", len(y))
}
Output
Before appending...
y: QuoteRuneToASCII_Test:
Length(y): 22
After appending...
y: QuoteRuneToASCII_Test:'b''\U0001f34e''\U0001f34c''\U0001f352'
Length(y): 61
That’s it!

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.