Commit 4fe9f574 authored by Rob Pike's avatar Rob Pike

fmt: allow %U for unsigned integers.

Suggested by jan.mercl@nic.cz.

R=rsc, jnml
CC=golang-dev
https://golang.org/cl/4376054
parent 11e07d23
...@@ -170,6 +170,7 @@ var fmttests = []struct { ...@@ -170,6 +170,7 @@ var fmttests = []struct {
// unicode format // unicode format
{"%U", 0x1, "U+0001"}, {"%U", 0x1, "U+0001"},
{"%U", uint(0x1), "U+0001"},
{"%.8U", 0x2, "U+00000002"}, {"%.8U", 0x2, "U+00000002"},
{"%U", 0x1234, "U+1234"}, {"%U", 0x1234, "U+1234"},
{"%U", 0x12345, "U+12345"}, {"%U", 0x12345, "U+12345"},
......
...@@ -389,6 +389,8 @@ func (p *pp) fmtUint64(v uint64, verb int, goSyntax bool, value interface{}) { ...@@ -389,6 +389,8 @@ func (p *pp) fmtUint64(v uint64, verb int, goSyntax bool, value interface{}) {
p.fmt.integer(int64(v), 16, unsigned, ldigits) p.fmt.integer(int64(v), 16, unsigned, ldigits)
case 'X': case 'X':
p.fmt.integer(int64(v), 16, unsigned, udigits) p.fmt.integer(int64(v), 16, unsigned, udigits)
case 'U':
p.fmtUnicode(int64(v))
default: default:
p.badVerb(verb, value) p.badVerb(verb, value)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment