Skip to content

Commit a0ca5b9

Browse files
committed
change chunk size to 4 bytes
1 parent 2d86734 commit a0ca5b9

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ RRD RBO RKD M DRBU MBRRRKD RDOR
3131

3232
You can also use emojis:
3333
```shell
34-
$ echo -n uwonsmth | aces 🥇🥈🥉
35-
🥇🥉🥇🥇🥉🥈🥇🥈🥈🥉🥈🥉🥈🥈🥈🥉🥇🥈🥇🥈🥇🥇🥇🥈🥉🥈🥈🥈🥉🥉🥉🥇🥈🥈🥉🥉🥉🥉🥇🥇🥈
34+
$ echo -n yay | aces 🥇🥈🥉
35+
🥇🥈🥉🥇🥉🥇🥉🥉🥇🥉🥉🥇🥈🥇🥉🥇🥉🥉🥇🥉🥇🥈🥇
3636
```
3737

3838
With Aces, you can see the actual 0s and 1s of files:
@@ -80,7 +80,7 @@ Examples:
8080
echo Calculus | aces 01 # what's stuff in binary?
8181
echo Aces™ | base64 | aces -d
8282
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ # even decode base64
83-
echo -n uwonsmth | aces 🥇🥈🥉 # emojis work too!
83+
echo -n yay | aces 🥇🥈🥉 # emojis work too!
8484
Set the encoding/decoding buffer size with --bufsize <size> (default 16KiB).
8585

8686
File issues, contribute or star at github.com/quackduck/aces

aces.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const defaultBufSize = 16 * 1024
1414

1515
// size of the byte chunk whose base is converted at a time when the length of the character
1616
// set is not a power of 2. See NewCoding for more detail.
17-
const defaultNonPow2ByteChunkSize = 8
17+
const defaultNonPow2ByteChunkSize = 4
1818

1919
// sliceByteLen slices the byte b such that the result has length len and starting bit start
2020
func sliceByteLen(b byte, start uint8, len uint8) byte {
@@ -177,7 +177,7 @@ type Coding interface {
177177
//
178178
// This is because most encoders interpret data as a number and use a base conversion algorithm to convert it to the
179179
// character set. For non-power-of-2 charsets, this requires all data to be read before encoding, which is not possible
180-
// with streams. To enable stream encoding for non-power-of-2 charsets, Aces converts a default of 8 bytes (adjustable
180+
// with streams. To enable stream encoding for non-power-of-2 charsets, Aces converts a default of 4 bytes (adjustable
181181
// with Coding.SetByteChunkSize) of data at a time, which is not the same as converting the base of the entire data.
182182
func NewCoding(charset []rune) (Coding, error) {
183183
seen := make(map[rune]bool)
@@ -329,9 +329,9 @@ func (c *anyCoding) Encode(dst io.Writer, src io.Reader) error {
329329

330330
var resultBuf = make([]rune, 0, 64)
331331

332-
func encodeByteChunk(set []rune, octet []byte, rPerChunk int) []rune {
332+
func encodeByteChunk(set []rune, chunk []byte, rPerChunk int) []rune {
333333
resultBuf = resultBuf[:0]
334-
i := bytesToInt(octet)
334+
i := bytesToInt(chunk)
335335
resultBuf = toBase(i, resultBuf, set)
336336
//return append([]rune(strings.Repeat(string(set[0]), rPerChunk-len(resultBuf))), resultBuf...)
337337
for len(resultBuf) < rPerChunk {

cmd/aces/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Examples:
2727
echo Calculus | aces 01 # what's stuff in binary?
2828
echo Aces™ | base64 | aces -d
2929
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ # even decode base64
30-
echo -n uwonsmth | aces 🥇🥈🥉 # emojis work too!
30+
echo -n yay | aces 🥇🥈🥉 # emojis work too!
3131
Set the encoding/decoding buffer size with --bufsize <size> (default 16KiB).
3232
3333
File issues, contribute or star at github.com/quackduck/aces`

0 commit comments

Comments
 (0)