Skip to content

Commit

Permalink
fiexs bytes viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Dec 3, 2018
1 parent 0bade5e commit e9ebb2e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bytes_viewer.go
@@ -1,8 +1,10 @@
package ffmt

import (
"bytes"
"fmt"
"strconv"
"unicode"
"unsafe"
)

Expand Down Expand Up @@ -33,14 +35,23 @@ func (b BytesViewer) String() string {
k = len(b)
}
for j := i; j != k; j++ {
if b[j] < 16 {
result = append(result, '0')
}
result = strconv.AppendUint(result, uint64(b[j]), 16)
result = append(result, ' ')
}
for j := 0; j != more; j++ {
result = append(result, " "...)
}
result = append(result, "| "...)
result = append(result, b[i:k]...)
buf := bytes.Map(func(r rune) rune {
if unicode.IsSpace(r) {
return ' '
}
return r
}, b[i:k])
result = append(result, buf...)
for j := 0; j != more; j++ {
result = append(result, ' ')
}
Expand Down

0 comments on commit e9ebb2e

Please sign in to comment.