### Go Benchmark Results Source: https://github.com/mroth/base100-go/blob/main/README.md Performance benchmarks for Base100 Go library on an Apple M2 Pro. Shows throughput for encoding and decoding operations. ```go go test -bench=. -cpu=1 goos: darwin goarch: arm64 pkg: github.com/mroth/base100-go cpu: Apple M2 Pro BenchmarkEncode 24076875 49.24 ns/op 913.81 MB/s BenchmarkEncodeToString 12909928 90.94 ns/op 494.83 MB/s BenchmarkDecode 31709400 37.85 ns/op 1189.02 MB/s BenchmarkDecodeString 25889036 45.45 ns/op 990.11 MB/s BenchmarkEncoder 18339 65083 ns/op 1006.96 MB/s BenchmarkDecoder 21528 56465 ns/op 1160.65 MB/s ``` -------------------------------- ### Base100 CLI Usage Source: https://github.com/mroth/base100-go/blob/main/README.md The command-line tool encodes or decodes input. It reads from stdin by default and writes UTF-8 to stdout. Use the --decode flag for decoding. ```bash base100 (Go) Encodes things into emoji USAGE: base100 [FLAGS] FLAGS: -d, --decode Decodes input -i, --input Input file (default use STDIN) -o, --output Output file (default use STDOUT) -h, --help Prints help information ``` -------------------------------- ### Encode File to Base100 Source: https://context7.com/mroth/base100-go/llms.txt Encode the content of a file into Base100 format and save it to an output file. Use the -i flag for input file and -o flag for output file. ```bash # Encode a file base100 -i input.txt -o encoded.txt ``` -------------------------------- ### Encode byte slice to string Source: https://context7.com/mroth/base100-go/llms.txt Convenience function that returns an encoded base100 string, handling internal buffer allocation. ```go package main import ( "fmt" "github.com/mroth/base100-go" ) func main() { src := []byte("Hello, World!") encoded := base100.EncodeToString(src) fmt.Println(encoded) // Output: 👟👜👣👣👦👊🐗👮👦👩👣👛👄 } ``` -------------------------------- ### Stream decode data Source: https://context7.com/mroth/base100-go/llms.txt Wraps an io.Reader to perform streaming base100 decoding, useful for processing large encoded streams. ```go package main import ( "bytes" "fmt" "io" "github.com/mroth/base100-go" ) func main() { encoded := []byte("👟👜👣👣👦🐗👮👦👩👣👛") reader := bytes.NewReader(encoded) decoder := base100.NewDecoder(reader) decoded, err := io.ReadAll(decoder) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Decoded: %s\n", decoded) // Output: Decoded: hello world } ``` -------------------------------- ### Stream encode data Source: https://context7.com/mroth/base100-go/llms.txt Wraps an io.Writer to perform streaming base100 encoding, suitable for large data sets. ```go package main import ( "bytes" "fmt" "io" "github.com/mroth/base100-go" ) func main() { var buf bytes.Buffer encoder := base100.NewEncoder(&buf) // Write data in chunks (simulating streaming) data := []byte("streaming data example") io.WriteString(encoder, string(data)) fmt.Printf("Encoded: %s\n", buf.String()) // Output: Encoded: 👪👫👩👜👘👤👠👥👞🐗👛👘👫👘🐗👜👯👘👤👧👣👜 } ``` -------------------------------- ### Encode byte slice to base100 Source: https://context7.com/mroth/base100-go/llms.txt Encodes a byte slice into a pre-allocated destination buffer. Each input byte results in a 4-byte UTF-8 emoji sequence. ```go package main import ( "fmt" "github.com/mroth/base100-go" ) func main() { src := []byte("the quick brown fox jumped over the lazy dog\n") dst := make([]byte, base100.EncodedLen(len(src))) base100.Encode(dst, src) fmt.Printf("%s", dst) // Output: 👫👟👜🐗👨👬👠👚👢🐗👙👩👦👮👥🐗👝👦👯🐗👡👬👤👧👜👛🐗👦👭👜👩🐗👫👟👜🐗👣👘👱👰🐗👛👦👞🐁 } ``` -------------------------------- ### Decode Base100 File Source: https://context7.com/mroth/base100-go/llms.txt Decode a Base100 encoded file and save the result to an output file. Use the -d flag for decoding, -i for input file, and -o for output file. ```bash # Decode a file base100 -d -i encoded.txt -o output.txt ``` -------------------------------- ### NewDecoder Source: https://context7.com/mroth/base100-go/llms.txt Creates a new base100 stream decoder that wraps an io.Reader. Data read from the returned reader will be decoded from base100 format. Useful for processing large encoded streams efficiently. ```APIDOC ## NewDecoder ### Description Creates a new base100 stream decoder that wraps an `io.Reader`. Data read from this decoder will be base100 decoded from the underlying reader. This is efficient for processing large encoded streams. ### Method `NewDecoder` ### Parameters #### Input - `r` (io.Reader) - The underlying reader from which encoded data will be read. ### Returns - `*base100.Decoder` - A new base100 decoder. ### Request Example ```go package main import ( "bytes" "fmt" "io" "github.com/mroth/base100-go" ) func main() { encoded := []byte("👟👜👣👣👦🐗👮👦👩👣👛") reader := bytes.NewReader(encoded) decoder := base100.NewDecoder(reader) decoded, err := io.ReadAll(decoder) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Decoded: %s\n", decoded) } ``` ### Response Example ``` Decoded: hello world ``` ``` -------------------------------- ### Encode Text to Base100 Source: https://context7.com/mroth/base100-go/llms.txt Use this command to encode plain text into Base100 emoji representation. It reads from standard input and writes the encoded output to standard output. ```bash # Encode text to base100 echo "Hello World" | base100 # Output: 👟👜👣👣👦🐗👮👦👩👣👛🐁 ``` -------------------------------- ### EncodedLen Source: https://context7.com/mroth/base100-go/llms.txt Returns the length in bytes of the base100 encoding of an input buffer of length n. Each input byte produces 4 bytes of output (one 4-byte UTF-8 emoji). ```APIDOC ## EncodedLen ### Description Returns the length in bytes of the base100 encoding for a given input buffer length. ### Method `EncodedLen` ### Parameters #### Input - `n` (int) - The length of the input byte buffer. ### Request Example ```go package main import ( "fmt" "github.com/mroth/base100-go" ) func main() { inputLen := 10 outputLen := base100.EncodedLen(inputLen) fmt.Printf("Input: %d bytes -> Output: %d bytes\n", inputLen, outputLen) } ``` ### Response Example ``` Input: 10 bytes -> Output: 40 bytes ``` ``` -------------------------------- ### Calculate encoded length Source: https://context7.com/mroth/base100-go/llms.txt Determines the required buffer size for base100 encoding based on input length. ```go package main import ( "fmt" "github.com/mroth/base100-go" ) func main() { inputLen := 10 outputLen := base100.EncodedLen(inputLen) fmt.Printf("Input: %d bytes -> Output: %d bytes\n", inputLen, outputLen) // Output: Input: 10 bytes -> Output: 40 bytes } ``` -------------------------------- ### NewEncoder Source: https://context7.com/mroth/base100-go/llms.txt Creates a new base100 stream encoder that wraps an io.Writer. Data written to the returned writer will be encoded using base100 and then written to the underlying writer. Ideal for streaming large amounts of data. ```APIDOC ## NewEncoder ### Description Creates a new base100 stream encoder that wraps an `io.Writer`. Data written to this encoder will be base100 encoded before being written to the underlying writer. This is suitable for processing large data streams. ### Method `NewEncoder` ### Parameters #### Input - `w` (io.Writer) - The underlying writer to which encoded data will be written. ### Returns - `*base100.Encoder` - A new base100 encoder. ### Request Example ```go package main import ( "bytes" "fmt" "io" "github.com/mroth/base100-go" ) func main() { var buf bytes.Buffer encoder := base100.NewEncoder(&buf) data := []byte("streaming data example") io.WriteString(encoder, string(data)) fmt.Printf("Encoded: %s\n", buf.String()) } ``` ### Response Example ``` Encoded: 👪👫👩👜👘👤👠👥👞🐗👛👘👫👘🐗👜👯👘👤👧👣👜 ``` ``` -------------------------------- ### Decode Base100 File with Long Flags Source: https://context7.com/mroth/base100-go/llms.txt Decode a Base100 encoded file using long flag names for clarity. This command is equivalent to `base100 -d -i encoded.txt -o output.txt`. ```bash # Using long flags base100 --decode --input encoded.txt --output output.txt ``` -------------------------------- ### Decode base100 string Source: https://context7.com/mroth/base100-go/llms.txt Convenience function to decode a base100 string directly into a byte slice. ```go package main import ( "fmt" "log" "github.com/mroth/base100-go" ) func main() { src := "👟👜👣👣👦👊🐗👮👦👩👣👛👄" result, err := base100.DecodeString(src) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", result) // Output: Hello, World! } ``` -------------------------------- ### Decode Base100 to Text Source: https://context7.com/mroth/base100-go/llms.txt Use this command to decode Base100 emoji representation back into plain text. It reads the encoded input from standard input and writes the decoded output to standard output. ```bash # Decode base100 back to text echo "👟👜👣👣👦🐗👮👦👩👣👛🐁" | base100 -d # Output: Hello World ``` -------------------------------- ### DecodeString Source: https://context7.com/mroth/base100-go/llms.txt Convenience function that decodes a base100 string directly to bytes. Returns the decoded bytes and any error encountered. ```APIDOC ## DecodeString ### Description Convenience function that decodes a base100 encoded string directly into a byte slice. Returns the decoded bytes and any error encountered. ### Method `DecodeString` ### Parameters #### Input - `src` (string) - The base100 encoded string. ### Returns - `result` ([]byte) - The decoded byte slice. - `err` (error) - Any error encountered during decoding. ### Request Example ```go package main import ( "fmt" "log" "github.com/mroth/base100-go" ) func main() { src := "👟👜👣👣👦👊🐗👮👦👩👣👛👄" result, err := base100.DecodeString(src) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", result) } ``` ### Response Example ``` Hello, World! ``` ``` -------------------------------- ### EncodeToString Source: https://context7.com/mroth/base100-go/llms.txt Convenience function that encodes a byte slice directly to a base100 string. This allocates a new buffer internally and returns the encoded result as a string. ```APIDOC ## EncodeToString ### Description Convenience function that encodes a byte slice directly to a base100 string. It allocates a new buffer internally and returns the encoded result as a string. ### Method `EncodeToString` ### Parameters #### Input - `src` ([]byte) - The source byte slice to encode. ### Request Example ```go package main import ( "fmt" "github.com/mroth/base100-go" ) func main() { src := []byte("Hello, World!") encoded := base100.EncodeToString(src) fmt.Println(encoded) } ``` ### Response Example ``` 👟👜👣👣👦👊🐗👮👦👩👣👛👄 ``` ``` -------------------------------- ### Decode base100 data Source: https://context7.com/mroth/base100-go/llms.txt Decodes base100 encoded bytes into a destination buffer. Ensure newline characters are stripped from input before decoding. ```go package main import ( "fmt" "log" "github.com/mroth/base100-go" ) func main() { src := []byte("👫👟👜🐗👨👬👠👚👢🐗👙👩👦👮👥🐗👝👦👯🐗👡👬👤👧👜👛🐗👦👭👜👩🐗👫👟👜🐗👣👘👱👰🐗👛👦👞🐁") dst := make([]byte, base100.DecodedLen(len(src))) n, err := base100.Decode(dst, src) if err != nil { log.Fatal(err) } fmt.Printf("Decoded %d bytes: %s", n, dst) // Output: Decoded 45 bytes: the quick brown fox jumped over the lazy dog } ``` -------------------------------- ### Encode Source: https://context7.com/mroth/base100-go/llms.txt Encodes a byte slice to its base100 emoji representation. The `Encode` function writes `EncodedLen(len(src))` bytes to the destination buffer, where each input byte is converted to a 4-byte UTF-8 emoji sequence. ```APIDOC ## Encode ### Description Encodes a byte slice to its base100 emoji representation. Each input byte is converted to a 4-byte UTF-8 emoji sequence. ### Method `Encode` ### Parameters #### Input - `dst` ([]byte) - The destination buffer to write the encoded data. - `src` ([]byte) - The source byte slice to encode. ### Request Example ```go package main import ( "fmt" "github.com/mroth/base100-go" ) func main() { src := []byte("the quick brown fox jumped over the lazy dog\n") dst := make([]byte, base100.EncodedLen(len(src))) base100.Encode(dst, src) fmt.Printf("%s", dst) } ``` ### Response Example ``` 👫👟👜🐗👨👬👠👚👢🐗👙👩👦👮👥🐗👝👦👯🐗👡👬👤👧👜👛🐗👦👭👜👩🐗👫👟👜🐗👣👘👱👰🐗👛👦👞🐁 ``` ``` -------------------------------- ### Decode Source: https://context7.com/mroth/base100-go/llms.txt Decodes base100 encoded data back to original bytes. Returns the number of bytes written and any error encountered. Note that newline characters (\r and \n) should be stripped from input beforehand. ```APIDOC ## Decode ### Description Decodes base100 encoded data back to its original byte representation. It's recommended to strip newline characters from the input before decoding. ### Method `Decode` ### Parameters #### Input - `dst` ([]byte) - The destination buffer to write the decoded data. - `src` ([]byte) - The base100 encoded byte slice. ### Returns - `n` (int) - The number of bytes written to the destination buffer. - `err` (error) - Any error encountered during decoding. ### Request Example ```go package main import ( "fmt" "log" "github.com/mroth/base100-go" ) func main() { src := []byte("👫👟👜🐗👨👬👠👚👢🐗👙👩👦👮👥🐗👝👦👯🐗👡👬👤👧👜👛🐗👦👭👜👩🐗👫👟👜🐗👣👘👱👰🐗👛👦👞🐁") dst := make([]byte, base100.DecodedLen(len(src))) n, err := base100.Decode(dst, src) if err != nil { log.Fatal(err) } fmt.Printf("Decoded %d bytes: %s", n, dst) } ``` ### Response Example ``` Decoded 45 bytes: the quick brown fox jumped over the lazy dog ``` ``` -------------------------------- ### Calculate decoded length Source: https://context7.com/mroth/base100-go/llms.txt Returns the maximum possible length of decoded data for a given encoded length. ```go package main import ( "fmt" "github.com/mroth/base100-go" ) func main() { encodedLen := 40 decodedLen := base100.DecodedLen(encodedLen) fmt.Printf("Encoded: %d bytes -> Decoded: %d bytes max\n", encodedLen, decodedLen) // Output: Encoded: 40 bytes -> Decoded: 10 bytes max } ``` -------------------------------- ### DecodedLen Source: https://context7.com/mroth/base100-go/llms.txt Returns the maximum length in bytes of the decoded data corresponding to n bytes of base100-encoded data. ```APIDOC ## DecodedLen ### Description Calculates the maximum possible length in bytes of the decoded data given the length of the base100-encoded data. ### Method `DecodedLen` ### Parameters #### Input - `n` (int) - The length of the base100 encoded data in bytes. ### Request Example ```go package main import ( "fmt" "github.com/mroth/base100-go" ) func main() { encodedLen := 40 decodedLen := base100.DecodedLen(encodedLen) fmt.Printf("Encoded: %d bytes -> Decoded: %d bytes max\n", encodedLen, decodedLen) } ``` ### Response Example ``` Encoded: 40 bytes -> Decoded: 10 bytes max ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.