66
77# KEncode
88
9- ** High-efficiency binary/text codecs with compact bit-packed serialization for Kotlin.**
9+ ** High-efficiency binary/text codecs with compact bit-packed serialization for
10+ Kotlin.**
1011
1112![ Maven Central] ( https://img.shields.io/maven-central/v/com.eignex/kencode.svg?label=Maven%20Central )
1213![ Build] ( https://github.com/eignex/kencode/actions/workflows/build.yml/badge.svg )
@@ -32,15 +33,20 @@ representations:
3233 data.
3334
34352 . ** Standalone BinaryFormat** : ` PackedFormat `
35- Compact binary serialization for flat structures using bitmasks and
36- varints.
37- Use ` kotlinx.serialization.ProtoBuf ` instead when you need nesting, lists, or
38- maps.
36+ A binary serializer for flat Kotlin serializable classes. It uses a bitset
37+ for booleans and nullability, and varint encodings for integers. It avoids
38+ support for nesting or collections in order to keep the layout small and
39+ predictable. Use ` kotlinx.serialization.ProtoBuf ` when hierarchical
40+ structures are required.
3941
40423 . ** Standalone StringFormat** : ` EncodedFormat `
41- Adds checksum + text encoding on top of a binary format, providing very short
42- string formats.
43+ A wrapper that applies a binary format, optionally appends a checksum, and
44+ then encodes the final byte sequence using a chosen ` ByteEncoding ` . This
45+ produces short, deterministic string representations suitable for external
46+ identifiers.
4347
48+ These components define explicit data layouts and predictable output lengths,
49+ enabling efficient transport, storage, and comparison of serialized values.
4450---
4551
4652## Installation
@@ -201,13 +207,13 @@ val decoded = format.decodeFromString<Command>(encoded)
201207
202208## PackedFormat explanation
203209
204- ` PackedFormat ` is a ` BinaryFormat ` designed to produce very small payloads for *
205- * flat** Kotlin data classes. It avoids nesting and collections, allowing a
206- compact and deterministic binary layout.
210+ ` PackedFormat ` is a ` BinaryFormat ` designed to produce very small payloads for
211+ ** flat** Kotlin serializable classes. It avoids nesting and collections,
212+ allowing a compact and deterministic binary layout.
207213
208214### Field layout
209215
210- For a single data class, the encoding consists of:
216+ For a single class, the encoding consists of:
211217
2122181 . ** Flags varlong**
213219
@@ -250,7 +256,8 @@ data class Counters(
250256ASCII-safe tokens by composing three layers:
251257
2522581 . ** Binary format**
253- Default is ` PackedFormat ` , but any ` BinaryFormat ` (e.g. ProtoBuf) can be used.
259+ Default is ` PackedFormat ` , but any ` BinaryFormat ` (e.g. ProtoBuf) can be
260+ used.
254261
2552622 . ** Checksum (optional)**
256263 Supports ` Crc16 ` , ` Crc32 ` , or a custom implementation.
@@ -286,15 +293,18 @@ KEncode includes a focused set of practical ASCII-safe encoders: `Base36`,
286293` Base62 ` , ` Base64 ` , and ` Base85 ` . All implementations allow custom alphabets.
287294
288295### Base64 and URL-safe Base64
296+
289297* RFC 4648–compatible.
290298* 3 bytes → 4 characters (` = ` padding).
291299* URL-safe variant substitutes ` - ` and ` _ ` .
292300
293301### Base85
302+
294303* 4 bytes → 5 characters.
295304* Supports partial final groups (1–3 bytes).
296305* No delimiters or ` z ` compression.
297306
298307### Base36 / Base62 / custom alphabets
308+
299309Built on ` BaseRadix ` , these encoders use fixed-size blocks for predictable
300310lengths and safe decoding, without padding. Custom alphabets are supported.
0 commit comments