aboutsummaryrefslogtreecommitdiff
path: root/ber/bits.go
diff options
context:
space:
mode:
Diffstat (limited to 'ber/bits.go')
-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
+}