Skip to content

Commit 803e211

Browse files
committed
Added codec: base11
1 parent 3076c9f commit 803e211

2 files changed

Lines changed: 17 additions & 21 deletions

File tree

codext/base/baseN.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@
3939

4040

4141
B10 = {r'': "0123456789"}
42-
base(B10, r"^(?:base[-_]?10|int(?:eger)?)$")
42+
base(B10, r"^(?:base[-_]?10|int(?:eger)?|dec(?:imal)?)$")
4343
main10 = main(10)
4444

4545

46+
B11 = {r'': "0123456789a", r'[-_]inv(erted)?$': "a0123456789"}
47+
base(B11, r"^base[-_]?11(|[-_]inv(?:erted)?)$")
48+
main11 = main(11)
49+
50+
4651
B16 = {'': digits + "ABCDEF", '[-_]inv(erted)?$': "ABCDEF" + digits}
4752
base2n(B16, r"^(?:base[-_]?16|hex)(|[-_]inv(?:erted)?)$", expansion_factor=2.)
4853
main16 = main(16, "RFC 4648")

docs/enc/base.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Common base encodings with N a power of 2:
1212

1313
**Codec** | **Conversions** | **Aliases** | **Comment**
1414
:---: | :---: | --- | ---
15-
`base2` | text <-> Base2 encoded text | `(base[-_]?2|bin)-inv(erted)?` |
16-
`base4` | text <-> Base4 encoded text | `base[-_]?4-inv(erted)` | charset: `1234`
17-
`base8` | text <-> Base8 encoded text | `base[-_]?8-inv(erted)` | charset: `abcdefgh`
15+
`base2` | text <-> Base2 encoded text | `(base[-_]?2|bin)-inv(erted)?` | Dynamic charset parameter `[-_]...`, amongst letters and digits (e.g. `_AB`)
16+
`base4` | text <-> Base4 encoded text | `base[-_]?4-inv(erted)` | Dynamic charset parameter `[-_]...`, amongst letters and digits (e.g. `_6VC9`)
17+
`base8` | text <-> Base8 encoded text | `base[-_]?8-inv(erted)` | Charset: `abcdefgh` ; Dynamic charset parameter `[-_]...`, amongst letters and digits (e.g. `_A5c96T7x`)
1818
`base16` | text <-> Base16 encoded text | `base[-_]?16-inv(erted)` |
19-
`base32` | text <-> Base32 encoded text | `base[-_]?32-inv(erted)` |
20-
`zbase32` | text <-> ZBase32 encoded text | `z[-_]?base[-_]?32` | human-oriented Base32
19+
`base32` | text <-> Base32 encoded text | `base[-_]?32-inv(erted)`, `base32-crockford`, `base32_geohash`, ... | Also supports Base32 Crockford, Geohash and Hex
20+
`zbase32` | text <-> ZBase32 encoded text | `z[-_]?base[-_]?32` | Human-oriented Base32
2121
`base64` | text <-> Base64 encoded text | `base[-_]?64-inv(erted)` |
2222

2323
!!! note "Aliases"
@@ -62,10 +62,12 @@ Note that for `base64`, it overwrites the native `base64_codec` to also support
6262

6363
**Codec** | **Conversions** | **Aliases** | **Comment**
6464
:---: | :---: | --- | ---
65-
`base3` | text <-> Base3 encoded text | `base[-_]?36(|[-_]inv(erted)?)` |
65+
`base3` | text <-> Base3 encoded text | `base[-_]?3(|[-_]inv(erted)?)` | Dynamic charset parameter `[-_]...`, amongst letters and digits (e.g. `_C2Z`)
66+
`base10` | text <-> Base10 encoded text | `base[-_]?10|int(?:eger)?|dec(?:imal)?` |
67+
`base11` | text <-> Base11 encoded text | `base[-_]?11(|[-_]inv(erted)?)` |
6668
`base36` | text <-> Base36 encoded text | `base[-_]?36(|[-_]inv(erted)?)` |
6769
`base45` | text <-> Base45 encoded text | `base[-_]?45(|[-_]inv(erted)?)` |
68-
`base58` | text <-> Base58 encoded text | `base[-_]?58(|[-_](bc|bitcoin|rp|ripple|fl|flickr|short[-]?url|url))` | supports Bitcoin, Ripple and short URL
70+
`base58` | text <-> Base58 encoded text | `base[-_]?58(|[-_](bc|bitcoin|rp|ripple|fl|flickr|short[-]?url|url))` | Supports Bitcoin, Ripple and short URL
6971
`base62` | text <-> Base62 encoded text | `base[-_]?62(|[-_]inv(erted)?)` |
7072
`base63` | text <-> Base63 encoded text | `base[-_]?63(|[-_]inv(erted)?)` |
7173
`base91` | text <-> Base91 encoded text | `base[-_]?91(|[-_]inv(erted)?)` |
@@ -131,11 +133,7 @@ This encoding implements various different versions of Base85.
131133

132134
**Codec** | **Conversions** | **Aliases** | **Comment**
133135
:---: | :---: | --- | ---
134-
`base85` | text <-> ascii85 | `ascii85` |
135-
`base85` | text <-> z85 | `z85`, `base85-zeromq` |
136-
`base85` | text <-> base85-ipv6 | `base85-ipv6`, `base85-rfc1924` |
137-
`base85` | text <-> base85-adobe | `base85-adobe` |
138-
`base85` | text <-> base85-btoa | `base85-btoa`, `base85-xbtoa` |
136+
`base85` | text <-> ascii85 | `(base[-_]?85(?:|[-_](?:adobe|x?btoa|ipv6|rfc1924|xml|z(?:eromq)?))|z85|ascii85)` |
139137

140138
```python
141139
>>> codext.encode("this is a test", "ascii85")
@@ -156,16 +154,9 @@ This encoding implements various different versions of Base85.
156154

157155
**Codec** | **Conversions** | **Aliases** | **Comment**
158156
:---: | :---: | --- | ---
159-
`base85` | text <-> Base85 encoded text | `base[-_]?85` | Python 3 only (relies on `base64` module)
160157
`base100` | text <-> Base100 encoded text | `base[-_]?100|emoji` | Python 3 only
161158
`base122` | text <-> Base122 encoded text | `base[-_]?122` | Python 3 only
162-
163-
```python
164-
>>> codecs.encode("this is a test", "base85")
165-
'bZBXFAZc?TVIXv6b94'
166-
>>> codecs.decode("bZBXFAZc?TVIXv6b94", "base85")
167-
'this is a test'
168-
```
159+
`base128` | text <-> Base128 encoded text | `base[-_]?128` | Relies on the ASCII charset
169160

170161
```python
171162
>>> codecs.encode("this is a test", "base100")

0 commit comments

Comments
 (0)