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
#### Base-78, using emoji as output (just for fun)
196
-
> **Note:** This example is aimed at Python 3 and may not work on Python 2 without some modification (or at all).
197
-
198
-
Unicode character ranges `0x1F601` through to `0x1F64F` are allocated for *emoticon emoji*. This range provides us with 78 characters to play with.
199
-
200
-
First of all, let's find us some appropriate encoding ratios within given ranges:
201
-
202
-
```py
203
-
>>>from basest.core import best_ratio
204
-
>>> best_ratio(256, [78], range(2, 1024))
205
-
(78, (1019, 1297)) # hmm, maybe a bit too big
206
-
>>> best_ratio(256, [78], range(2, 16))
207
-
(78, (7, 9)) # we could probably go a bit larger but this will do
208
-
```
209
-
210
-
Now, let's choose a padding character from one of the other Unicode emoji codepages. I decided to choose the `bear face` emoji (:bear: / 🐻), codepoint `0x1F43B`.
211
-
212
-
With these chosen parameters and a body of input data (will use text for this example), we can put it all together:
213
-
214
-
```py
215
-
>>>from basest.core import encode
216
-
>>># input data variable
217
-
>>> message =...
218
-
>>> output = encode(
219
-
...256, [chr(i) for i inrange(256)], # input base and symbol table
220
-
...78, [chr(0x1F601+ o) for o inrange(78)], # output base and symbol table
221
-
...chr(0x1F43B), # padding character
222
-
...7, 9, # encoding ratio
223
-
... message
224
-
... )
225
-
```
226
-
227
-
Given this input message (in ASCII):
228
-
229
-
```
230
-
Fourscore and seven years ago our fathers brought forth on this
231
-
continent a new nation, conceived in liberty and dedicated to the
232
-
proposition that all men are created equal.
233
-
Now we are engaged in a great civil war, testing whether that nation
234
-
or any nation so conceived and so dedicated can long endure. We are
235
-
met on a great battle field of that war. We have come to dedicate a
236
-
portion of that field, as a final resting place for those who here
237
-
gave their lives that that nation might live. It is altogether
238
-
fitting and proper that we should do this.
239
-
But, in a larger sense, we can not dedicate - we can not consecrate
240
-
- we can not hallow - this ground. The brave men, living and dead,
241
-
who struggled here, have consecrated it, far above our poor power to
242
-
add or detract. The world will little note, nor long remember, what
243
-
we say here, but it can never forget what they did here. It is for
244
-
us the living, rather, to be dedicated here to the unfinished work
245
-
which they who fought here have thus far so nobly advanced. It is
246
-
rather for us to be here dedicated to the great task remaining
247
-
before us - that from these honored dead we take increased devotion
248
-
to that cause for which they gave the last full measure of devotion
249
-
- that we here highly resolve that these dead shall not have died in
250
-
vain - that this nation, under God, shall have a new birth of
251
-
freedom - and that government of the people, by the people, for the
0 commit comments