45 lines
1016 B
Go
45 lines
1016 B
Go
/*
|
|
Package binarystr parses and renders string (and other) representations of binary data.
|
|
To distinguish this package from [encoding/binary], this package refers to this string encoding format
|
|
as "bit encoding" or "bitstrings".
|
|
|
|
For example, the original data:
|
|
|
|
[]byte("test")
|
|
|
|
// Or:
|
|
// []byte{0x74, 0x65, 0x73, 0x74}
|
|
|
|
can be encoded to a bitstring via e.g. [BytesToStr]:
|
|
|
|
01110100011001010111001101110100
|
|
|
|
And even formatted via [FmtBinStr]:
|
|
|
|
// For example, FmtBinStr("01110100011001010111001101110100", "", "", " "):
|
|
01110100 01100101 01110011 01110100
|
|
|
|
// Or FmtBinStr("01110100011001010111001101110100", "", " ", "\n"):
|
|
0111 0100
|
|
0110 0101
|
|
0111 0011
|
|
0111 0100
|
|
|
|
Or can be converted to a series of "binary booleans" via e.g. [BytesToBool]:
|
|
|
|
[]bool{
|
|
false, true, true, true,
|
|
false, true, false, false,
|
|
|
|
false, true, true, false,
|
|
false, true, false, true,
|
|
|
|
false, true, true, true,
|
|
false, false, true, true,
|
|
|
|
false, true, true, true,
|
|
false, true, false, false,
|
|
}
|
|
*/
|
|
package binarystr
|