You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-16Lines changed: 33 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,35 +6,51 @@
6
6
7
7
# KEncode
8
8
9
-
**Compact, ASCII-safe encodings and ultra-small binary serialization for Kotlin, ideal for URLs, headers, file names, and other size-limited channels. Produces short and predictable payloads.**
9
+
**Compact, ASCII-safe encodings and ultra-small binary serialization for Kotlin,
10
+
ideal for URLs, headers, file names, and other size-limited channels. Produces
> KEncode produces short, predictable text payloads that fit into environments with strict character or length limits such as URLs, file names, Kubernetes labels, and log keys.
18
+
> KEncode produces short, predictable text payloads that fit into environments
19
+
> with strict character or length limits such as URLs, file names, Kubernetes
20
+
> labels, and log keys.
17
21
18
-
> It provides high-performance radix and base encoders, efficient integer coding, optional checksums, and a compact bit-packed serializer for flat data models.
22
+
> It provides high-performance radix and base encoders, efficient integer
23
+
> coding, optional checksums, and a compact bit-packed serializer for flat data
24
+
> models.
19
25
20
26
---
21
27
22
28
## Overview
23
29
24
-
KEncode brings together several compact encoding tools: radix formats like Base36 and Base62, dense ASCII-safe formats such as Base64 and ASCII85-style Base85, varint and zig-zag integer coding, CRC-16 and CRC-32 checksums, and a minimal-allocation bit-packed serializer built on `kotlinx.serialization`.
30
+
KEncode provides **three focused entry points**, all aimed at producing compact,
31
+
ASCII-safe representations:
25
32
26
-
These features help you move structured data through **channels with tight ASCII or size constraints**, including:
Low-level encoders/decoders for `ByteArray` values.
35
+
Useful when you already have binary data and only need an ASCII-safe
36
+
representation.
27
37
28
-
* URLs and query parameters
29
-
* File names
30
-
* Kubernetes pod names, labels, and annotations
31
-
* HTTP headers and cookies
32
-
* Message queue identifiers
33
-
* Log keys and structured logging fields
38
+
2.**Standalone BinaryFormat**: `PackedFormat`
39
+
Produce compact binary payloads from Kotlin objects using
40
+
`kotlinx.serialization``BinaryFormat`.
41
+
`PackedFormat` produces very small from flat structures using bitmasks,
42
+
varints, but no object nesting. Use `kotlinx.serialization.ProtoBuf` instead
43
+
when you need nested types, lists, or maps.
34
44
35
-
⚠️ Encrypt any payload that contains sensitive information.
45
+
3.**Standalone StringFormat**: `EncodedFormat`
46
+
Produce string payloads from Kotlin objects using `kotlinx.serialization`
47
+
`StringFormat`.
48
+
Encompasses a `BinaryFormat` + optional checksum + `ByteEncoding` text codec.
49
+
Use when you want a single `encodeToString` / `decodeFromString` API that
50
+
yields short, deterministic tokens.
36
51
37
-
The bit-packed serializer supports only flat structures. Use `ProtoBuf` from `kotlinx.serialization` when you need maps, nested types, or more complex layouts.
52
+
KEncode focuses on minimal outputs; encrypt the payload first if it contains
53
+
sensitive information.
38
54
39
55
---
40
56
@@ -55,7 +71,7 @@ You also need to load the serialization plugin.
55
71
56
72
## Full serialization example
57
73
58
-
Minimal example using the default `EncodedFormat` (Base62 + PackedFormat):
74
+
Minimal example using the default `EncodedFormat` (`Base62` + `PackedFormat`):
59
75
60
76
```kotlin
61
77
@Serializable
@@ -147,7 +163,8 @@ println(encoded)
147
163
val decoded = format.decodeFromString<ProtoBufRequired>(encoded)
148
164
```
149
165
150
-
This example relies on kotlinx protobuf implementation, which you install:
166
+
This example relies on kotlinx protobuf implementation, which you install:
0 commit comments