fmt: make %q work for integers, printing a quoted character literal.
R=rsc
CC=golang-dev
https://golang.org/cl/4556060
diff --git a/src/pkg/fmt/format.go b/src/pkg/fmt/format.go
index f9d2b4f..5dcfb96 100644
--- a/src/pkg/fmt/format.go
+++ b/src/pkg/fmt/format.go
@@ -296,6 +296,13 @@
f.padString(quoted)
}
+// fmt_qc formats the integer as a single-quoted, escaped Go character constant.
+// If the character is not valid Unicode, it will print '\ufffd'.
+func (f *fmt) fmt_qc(c int64) {
+ quoted := strconv.QuoteRune(int(c))
+ f.padString(quoted)
+}
+
// floating-point
func doPrec(f *fmt, def int) int {