aboutsummaryrefslogtreecommitdiff
path: root/ber
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-07-07 23:05:19 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-07-07 23:05:19 +0200
commit67214db30959788af713ab6e165dd3fc56fa6d2e (patch)
tree16bf6c6cf652939f979d45c587e96353eaab1e37 /ber
parent8b2ca579d8274fe8ce3b2d30165c99066762c73a (diff)
Display BitString
Diffstat (limited to 'ber')
-rw-r--r--ber/bits.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/ber/bits.go b/ber/bits.go
index 42474e5..107cd6b 100644
--- a/ber/bits.go
+++ b/ber/bits.go
@@ -16,3 +16,16 @@ func parseBitString(b []byte) (bs Bits) {
func UnmarshalBitString(b []byte) Bits {
return parseBitString(b)
}
+
+func (bs Bits) String() (s string) {
+ for i := 0; i < bs.Length; i++ {
+ x := i / 8
+ y := 7 - uint(i%8)
+ if bs.Bytes[x]&(1<<y) != 0 {
+ s += "1"
+ } else {
+ s += "0"
+ }
+ }
+ return
+}