summaryrefslogtreecommitdiff
path: root/libgo/go/strconv/quote.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/strconv/quote.go')
-rw-r--r--libgo/go/strconv/quote.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/libgo/go/strconv/quote.go b/libgo/go/strconv/quote.go
index 9b48c07fb1d..30b384df8e3 100644
--- a/libgo/go/strconv/quote.go
+++ b/libgo/go/strconv/quote.go
@@ -92,6 +92,12 @@ func Quote(s string) string {
return quoteWith(s, '"', false)
}
+// AppendQuote appends a double-quoted Go string literal representing s,
+// as generated by Quote, to dst and returns the extended buffer.
+func AppendQuote(dst []byte, s string) []byte {
+ return append(dst, Quote(s)...)
+}
+
// QuoteToASCII returns a double-quoted Go string literal representing s.
// The returned string uses Go escape sequences (\t, \n, \xFF, \u0100) for
// non-ASCII characters and non-printable characters as defined by
@@ -100,6 +106,12 @@ func QuoteToASCII(s string) string {
return quoteWith(s, '"', true)
}
+// AppendQuoteToASCII appends a double-quoted Go string literal representing s,
+// as generated by QuoteToASCII, to dst and returns the extended buffer.
+func AppendQuoteToASCII(dst []byte, s string) []byte {
+ return append(dst, QuoteToASCII(s)...)
+}
+
// QuoteRune returns a single-quoted Go character literal representing the
// rune. The returned string uses Go escape sequences (\t, \n, \xFF, \u0100)
// for control characters and non-printable characters as defined by
@@ -109,6 +121,12 @@ func QuoteRune(rune int) string {
return quoteWith(string(rune), '\'', false)
}
+// AppendQuoteRune appends a single-quoted Go character literal representing the rune,
+// as generated by QuoteRune, to dst and returns the extended buffer.
+func AppendQuoteRune(dst []byte, rune int) []byte {
+ return append(dst, QuoteRune(rune)...)
+}
+
// QuoteRuneToASCII returns a single-quoted Go character literal representing
// the rune. The returned string uses Go escape sequences (\t, \n, \xFF,
// \u0100) for non-ASCII characters and non-printable characters as defined
@@ -118,6 +136,12 @@ func QuoteRuneToASCII(rune int) string {
return quoteWith(string(rune), '\'', true)
}
+// AppendQuoteRune appends a single-quoted Go character literal representing the rune,
+// as generated by QuoteRuneToASCII, to dst and returns the extended buffer.
+func AppendQuoteRuneToASCII(dst []byte, rune int) []byte {
+ return append(dst, QuoteRuneToASCII(rune)...)
+}
+
// CanBackquote returns whether the string s would be
// a valid Go string literal if enclosed in backquotes.
func CanBackquote(s string) bool {