strconv.AppendQuoteRuneToASCII() Function in Golang With Examples
Last Updated :
12 Jul, 2025
Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides an
AppendQuoteRuneToASCII() function
which is used to append a single-quoted Go character literal representing the rune x, as generated by QuoteRuneToASCII, to num and returns the extended buffer. Or in other words, AppendQuoteRuneToASCII() function is used to convert Unicode characters to ASCII strings resulting from "single quotes", append the result to the end of num and return the appended []byte. To access AppendQuoteRuneToASCII() function you need to import strconv Package in your program.
Syntax:
func AppendQuoteRuneToASCII(num []byte, x rune) []byte
Here, num is []bytes and x is a rune literal. The result of x will append to the end of num.
Example 1:
// Golang program to illustrate the
// strconv.AppendQuoteRuneToASCII() function
package main
import (
"fmt"
"strconv"
)
func main() {
// Converting Unicode characters to
// ASCII strings resulting from "single quotes"
// append the result to the end of the given []byte
// Using AppendQuoteRuneToASCII() function
val1 := []byte("Rune 1: ")
val1 = strconv.AppendQuoteRuneToASCII(val1, 'B')
fmt.Println(string(val1))
val2 := []byte("Rune 2: ")
val2 = strconv.AppendQuoteRuneToASCII(val2, '✈')
fmt.Println(string(val2))
}
Output:
Rune 1: 'B'
Rune 2: '\u2708'
Example 2:
// Golang program to illustrate the
// strconv.AppendQuoteRuneToASCII() function
package main
import (
"fmt"
"strconv"
)
func main() {
// Converting Unicode characters to ASCII
// strings resulting from "single quotes"
// append the result to the end of the given []byte
// Using AppendQuoteRuneToASCII() function
val1 := []byte("Rune 1: ")
val1 = strconv.AppendQuoteRuneToASCII(val1, 'c')
fmt.Println(string(val1))
fmt.Println("Length: ", len(val1))
fmt.Println("Capacity: ", cap(val1))
val2 := []byte("Rune 2: ")
val2 = strconv.AppendQuoteRuneToASCII(val2, '❄')
fmt.Println(string(val2))
fmt.Println("Length: ", len(val2))
fmt.Println("Capacity: ", cap(val2))
}
Output:
Rune 1: 'c'
Length: 11
Capacity: 16
Rune 2: '\u265b'
Length: 16
Capacity: 16
Similar Reads
strconv.AppendQuoteToASCII() Function in Golang With Examples Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides an AppendQuoteToASCII() function which is used to append a double-quoted Go string literal representing str, as generated by QuoteToASCII, to
2 min read
strconv.AppendQuoteRune() Function in Golang With Examples Go language provides inbuilt support to implement conversions to and from string representations of basic data types with the help of strconv Package. This package provides an AppendQuoteRune() function which appends a single-quoted Go character literal representing the rune x, as generated by Quote
2 min read
strconv.AppendQuote() Function in Golang With Examples Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides an AppendQuote() function which appends a double-quoted Go string literal representing str, as generated by Quote, to num and returns the ext
2 min read
strconv.AppendUint() Function in Golang With Examples Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides an AppendUint() function which is used to append the string form of the unsigned integer x, as generated by FormatUint, to num and return the
2 min read
strconv.AppendInt() Function in Golang With Examples Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides an AppendInt() function which is used to append the string form of the integer val, as generated by FormatInt, to num and returns the extende
2 min read
strconv.AppendBool() Function in Golang With Examples Go language provides inbuilt support to implement conversions to and from string representations of basic data types by strconv Package. This package provides an AppendBool() function which is used to append bool(i.e, true or false) according to the value of num2 to num1 and returns the extended buf
1 min read