Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
afff0ff1
Commit
afff0ff1
authored
Nov 25, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
% x inserts spaces between hex bytes in string/*[]byte
R=r DELTA=7 (7 added, 0 deleted, 0 changed) OCL=19967 CL=19978
parent
ed490dbe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
0 deletions
+4
-0
fmt_test.go
src/lib/fmt/fmt_test.go
+1
-0
format.go
src/lib/fmt/format.go
+3
-0
No files found.
src/lib/fmt/fmt_test.go
View file @
afff0ff1
...
@@ -45,6 +45,7 @@ var fmttests = []FmtTest{
...
@@ -45,6 +45,7 @@ var fmttests = []FmtTest{
// basic bytes
// basic bytes
FmtTest
{
"%s"
,
Bytes
(
"abc"
),
"abc"
},
FmtTest
{
"%s"
,
Bytes
(
"abc"
),
"abc"
},
FmtTest
{
"%x"
,
Bytes
(
"abc"
),
"616263"
},
FmtTest
{
"%x"
,
Bytes
(
"abc"
),
"616263"
},
FmtTest
{
"% x"
,
Bytes
(
"abc"
),
"61 62 63"
},
FmtTest
{
"%x"
,
Bytes
(
"xyz"
),
"78797a"
},
FmtTest
{
"%x"
,
Bytes
(
"xyz"
),
"78797a"
},
FmtTest
{
"%X"
,
Bytes
(
"xyz"
),
"78797A"
},
FmtTest
{
"%X"
,
Bytes
(
"xyz"
),
"78797A"
},
FmtTest
{
"%q"
,
Bytes
(
"abc"
),
`"abc"`
},
FmtTest
{
"%q"
,
Bytes
(
"abc"
),
`"abc"`
},
...
...
src/lib/fmt/format.go
View file @
afff0ff1
...
@@ -374,6 +374,9 @@ func (f *Fmt) s(s string) *Fmt {
...
@@ -374,6 +374,9 @@ func (f *Fmt) s(s string) *Fmt {
func
(
f
*
Fmt
)
sx
(
s
string
)
*
Fmt
{
func
(
f
*
Fmt
)
sx
(
s
string
)
*
Fmt
{
t
:=
""
;
t
:=
""
;
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
for
i
:=
0
;
i
<
len
(
s
);
i
++
{
if
i
>
0
&&
f
.
space
{
t
+=
" "
;
}
v
:=
s
[
i
];
v
:=
s
[
i
];
t
+=
string
(
ldigits
[
v
>>
4
]);
t
+=
string
(
ldigits
[
v
>>
4
]);
t
+=
string
(
ldigits
[
v
&
0xF
]);
t
+=
string
(
ldigits
[
v
&
0xF
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment