@@ -21,16 +21,15 @@ keys.
2121
2222## Overview
2323
24- KEncode has three standalone entry points. ByteEncoding is a set of text codecs
25- ( Base62, Base36, Base64, Base85) for raw binary data .
24+ There are three entry points. ByteEncoding is a set of text codecs for raw
25+ binary data: Base62, Base36, Base64, Base85.
2626
27- PackedFormat is a kotlinx.serialization BinaryFormat that produces compact byte
28- payloads for Kotlin classes, including nested objects, lists, and maps.
27+ PackedFormat is a kotlinx.serialization BinaryFormat that emits compact byte
28+ payloads for Kotlin classes, with full support for nested objects, lists, and
29+ maps. EncodedFormat then layers a text codec and optional payload transforms
30+ on top, producing short, deterministic string identifiers.
2931
30- EncodedFormat layers a text codec and optional payload transforms over a binary
31- format to produce short, deterministic string identifiers.
32-
33- For a walkthrough of the bit-packing layout and design choices, see the
32+ For the design rationale and a walkthrough of the bit-packing layout, see the
3433[ technical deep dive] ( https://eignex.com/posts/kencode-packing-data-for-strict-limits/ ) .
3534
3635### Installation
@@ -71,13 +70,13 @@ val decoded = EncodedFormat.decodeFromString<Payload>(encoded)
7170
7271## PackedFormat
7372
74- PackedFormat is a BinaryFormat for Kotlin classes that emits compact byte
75- payloads. Booleans and nullability markers share a single bit-header ( about one
76- bit per field), and nested objects, lists, maps, and polymorphism are handled
73+ PackedFormat is a BinaryFormat aimed at the smallest feasible byte output.
74+ Booleans and nullability markers share a single bit-header, costing about one
75+ bit per field. Nested objects, lists, maps, and polymorphism all work
7776recursively.
7877
79- Int and Long fields can be annotated with @PackedType to choose unsigned varint
80- or ZigZag, and @ProtoType is recognized as a fallback.
78+ Int and Long fields take a @PackedType annotation to opt into unsigned varint
79+ or ZigZag. @ProtoType works as a fallback.
8180
8281``` kotlin
8382val compactFormat = PackedFormat {
@@ -93,17 +92,16 @@ val bytes = compactFormat.encodeToByteArray(payload)
9392
9493## EncodedFormat
9594
96- EncodedFormat is a StringFormat that produces short tokens by composing three
97- layers. The binary layer is PackedFormat by default, but ProtoBuf is a good
98- choice when cross-language compatibility matters.
95+ EncodedFormat is a StringFormat built from three composable layers.
9996
100- After serialization, an optional PayloadTransform can manipulate the bytes, for
101- example CompactZeros to strip leading zeros, Checksum to append an integrity
102- check, or a custom transform for encryption or error correction. Transforms
103- compose with PayloadTransform.then.
97+ The first is binary: PackedFormat by default, or ProtoBuf when cross-language
98+ compatibility matters. The second is an optional PayloadTransform that
99+ manipulates the bytes after serialization. CompactZeros strips leading zeros,
100+ Checksum appends an integrity check, and custom transforms cover encryption or
101+ error correction; chain them with PayloadTransform.then.
104102
105- Finally a text codec turns the bytes into a string, with Base62 as the default
106- and Base36, Base64, and Base85 available.
103+ A text codec finishes the job. Base62 is the default; Base36, Base64, and
104+ Base85 are also available.
107105
108106``` kotlin
109107val customFormat = EncodedFormat {
@@ -124,13 +122,12 @@ val withBoth = EncodedFormat {
124122
125123## Base Encoders
126124
127- KEncode ships standalone byte-to-text codecs, all of which accept custom
128- alphabets.
125+ All four codecs are usable on their own and accept custom alphabets.
129126
130- Base62 and Base36 use fixed-block encoding for predictable lengths without
131- padding, and produce purely alpha-numeric output (with or without upper-case).
132- Base85 trades alphabet size for density, encoding four bytes into five
133- characters. Base64 and Base64Url are RFC 4648 compatible.
127+ Base62 and Base36 use fixed-block encoding for predictable, unpadded output in
128+ a strictly alpha-numeric alphabet (with or without upper-case). Base85 is
129+ denser: four bytes in, five characters out. Base64 and Base64Url are RFC 4648
130+ compatible.
134131
135132Encoding ` "any byte data" ` (13 bytes):
136133
@@ -143,9 +140,9 @@ Encoding `"any byte data"` (13 bytes):
143140
144141## Extensions
145142
146- EncodedFormat can be extended by wrapping any byte transformation as a
147- PayloadTransform. The jvmTest source includes two worked examples : an
143+ Any byte transformation can be wrapped as a PayloadTransform. Two worked
144+ examples live in the jvmTest source : an
148145[ encryption transform] ( https://github.com/Eignex/kencode/blob/main/src/jvmTest/kotlin/com/eignex/kencode/EncryptionExample.kt )
149146built on BouncyCastle, and an
150147[ error-correction transform] ( https://github.com/Eignex/kencode/blob/main/src/jvmTest/kotlin/com/eignex/kencode/ErrorCorrectionExample.kt )
151- built on zxing that recovers from simulated byte corruption.
148+ on zxing that recovers from simulated byte corruption.
0 commit comments