1
0
mirror of https://github.com/golang/go synced 2024-11-21 21:54:40 -07:00

fmt: allow %U for unsigned integers.

Suggested by jan.mercl@nic.cz.

R=rsc, jnml
CC=golang-dev
https://golang.org/cl/4376054
This commit is contained in:
Rob Pike 2011-04-12 11:03:05 -07:00
parent 11e07d23ed
commit 4fe9f57413
2 changed files with 3 additions and 0 deletions

View File

@ -170,6 +170,7 @@ var fmttests = []struct {
// unicode format
{"%U", 0x1, "U+0001"},
{"%U", uint(0x1), "U+0001"},
{"%.8U", 0x2, "U+00000002"},
{"%U", 0x1234, "U+1234"},
{"%U", 0x12345, "U+12345"},

View File

@ -389,6 +389,8 @@ func (p *pp) fmtUint64(v uint64, verb int, goSyntax bool, value interface{}) {
p.fmt.integer(int64(v), 16, unsigned, ldigits)
case 'X':
p.fmt.integer(int64(v), 16, unsigned, udigits)
case 'U':
p.fmtUnicode(int64(v))
default:
p.badVerb(verb, value)
}