diff --git a/README.md b/README.md index 3b1de99..ffc1ca8 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ RRD RBO RKD M DRBU MBRRRKD RDOR You can also use emojis: ```shell -$ echo -n uwonsmth | aces πŸ₯‡πŸ₯ˆπŸ₯‰ -πŸ₯‡πŸ₯‰πŸ₯‡πŸ₯‡πŸ₯‰πŸ₯ˆπŸ₯‡πŸ₯ˆπŸ₯ˆπŸ₯‰πŸ₯ˆπŸ₯‰πŸ₯ˆπŸ₯ˆπŸ₯ˆπŸ₯‰πŸ₯‡πŸ₯ˆπŸ₯‡πŸ₯ˆπŸ₯‡πŸ₯‡πŸ₯‡πŸ₯ˆπŸ₯‰πŸ₯ˆπŸ₯ˆπŸ₯ˆπŸ₯‰πŸ₯‰πŸ₯‰πŸ₯‡πŸ₯ˆπŸ₯ˆπŸ₯‰πŸ₯‰πŸ₯‰πŸ₯‰πŸ₯‡πŸ₯‡πŸ₯ˆ +$ echo -n yay | aces πŸ₯‡πŸ₯ˆπŸ₯‰ +πŸ₯‡πŸ₯ˆπŸ₯‰πŸ₯‡πŸ₯‰πŸ₯‡πŸ₯‰πŸ₯‰πŸ₯‡πŸ₯‰πŸ₯‰πŸ₯‡πŸ₯ˆπŸ₯‡πŸ₯‰πŸ₯‡πŸ₯‰πŸ₯‰πŸ₯‡πŸ₯‰πŸ₯‡πŸ₯ˆπŸ₯‡ ``` With Aces, you can see the actual 0s and 1s of files: @@ -80,7 +80,7 @@ Examples: echo Calculus | aces 01 # what's stuff in binary? echo Acesβ„’ | base64 | aces -d ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ # even decode base64 - echo -n uwonsmth | aces πŸ₯‡πŸ₯ˆπŸ₯‰ # emojis work too! + echo -n yay | aces πŸ₯‡πŸ₯ˆπŸ₯‰ # emojis work too! Set the encoding/decoding buffer size with --bufsize (default 16KiB). File issues, contribute or star at github.com/quackduck/aces diff --git a/aces.go b/aces.go index a663381..cf9e01c 100644 --- a/aces.go +++ b/aces.go @@ -14,7 +14,7 @@ const defaultBufSize = 16 * 1024 // size of the byte chunk whose base is converted at a time when the length of the character // set is not a power of 2. See NewCoding for more detail. -const defaultNonPow2ByteChunkSize = 8 +const defaultNonPow2ByteChunkSize = 4 // sliceByteLen slices the byte b such that the result has length len and starting bit start func sliceByteLen(b byte, start uint8, len uint8) byte { @@ -177,7 +177,7 @@ type Coding interface { // // This is because most encoders interpret data as a number and use a base conversion algorithm to convert it to the // character set. For non-power-of-2 charsets, this requires all data to be read before encoding, which is not possible -// with streams. To enable stream encoding for non-power-of-2 charsets, Aces converts a default of 8 bytes (adjustable +// with streams. To enable stream encoding for non-power-of-2 charsets, Aces converts a default of 4 bytes (adjustable // with Coding.SetByteChunkSize) of data at a time, which is not the same as converting the base of the entire data. func NewCoding(charset []rune) (Coding, error) { seen := make(map[rune]bool) @@ -329,9 +329,9 @@ func (c *anyCoding) Encode(dst io.Writer, src io.Reader) error { var resultBuf = make([]rune, 0, 64) -func encodeByteChunk(set []rune, octet []byte, rPerChunk int) []rune { +func encodeByteChunk(set []rune, chunk []byte, rPerChunk int) []rune { resultBuf = resultBuf[:0] - i := bytesToInt(octet) + i := bytesToInt(chunk) resultBuf = toBase(i, resultBuf, set) //return append([]rune(strings.Repeat(string(set[0]), rPerChunk-len(resultBuf))), resultBuf...) for len(resultBuf) < rPerChunk { diff --git a/cmd/aces/main.go b/cmd/aces/main.go index 2ecf7d8..34d58e6 100644 --- a/cmd/aces/main.go +++ b/cmd/aces/main.go @@ -27,7 +27,7 @@ Examples: echo Calculus | aces 01 # what's stuff in binary? echo Acesβ„’ | base64 | aces -d ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ # even decode base64 - echo -n uwonsmth | aces πŸ₯‡πŸ₯ˆπŸ₯‰ # emojis work too! + echo -n yay | aces πŸ₯‡πŸ₯ˆπŸ₯‰ # emojis work too! Set the encoding/decoding buffer size with --bufsize (default 16KiB). File issues, contribute or star at github.com/quackduck/aces`