The AppendQuoteRuneToGraphic()
function of the strconv package is used to append the single-quoted Go character literal that represents r
(as generated by the QuoteRuneToGraphic()
function) to dst
and then return the extended buffer.
Note: The parameter
dst
is of type[]byte
andr
is of the typerune
.
func AppendQuoteRuneToGraphic(dst []byte, r rune) []byte
dst
: This is a byte array to which the single-quoted character is to be appended.r
: This is the rune character that is to be appended.The AppendQuoteRuneToGraphic()
function returns the extended buffer after appending the single-quoted character to dst
.
The following code shows us how to implement the AppendQuoteRuneToGraphic()
function in Golang.
// Using strconv.AppendQuoteRuneToGraphic() Functionpackage mainimport ("fmt""strconv")func main() {x := []byte("QuoteRuneToGraphic:")fmt.Println("Orignal value before AppendQuoteRuneToGraphic()", string(x))fmt.Println()// Append a character (rune 108 is the Unicode of l)x = strconv.AppendQuoteRuneToGraphic(x, 108)fmt.Println("The new Value after AppendQuoteRuneToGraphic()", string(x))fmt.Println()// Append emojix = strconv.AppendQuoteRuneToGraphic(x, '🙉')fmt.Println("The new Value after AppendQuoteRuneToGraphic()", string(x))fmt.Println()// Append emojix = strconv.AppendQuoteRuneToGraphic(x, '🙊')// Append a character (rune 95 is the Unicode of _)x = strconv.AppendQuoteRuneToGraphic(x, 95)fmt.Println("The new Value after AppendQuoteRuneToGraphic()", string(x))}
main
package.main()
function. Then, we define the variable r
of type rune
, assign a value to it, and pass it to the AppendQuoteRuneToGraphic()
function. This returns a single-quoted Go character literal that represents the given rune
value. Finally, we display the result.Note: All the values assigned to the variable
x
are appended to thedst
of type[]byte
.