Skip to content

Commit b18ddd4

Browse files
author
José Valim
committed
Update CHANGELOG
1 parent f4d852d commit b18ddd4

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# v0.13.0-dev
22

33
* Enhancements
4+
* [Base] Add `Base` module which does conversions to bases 16, 32, hex32, 64 and url64
5+
* [Code] Add `Code.eval_file/2`
46
* [Collectable] Add the `Collectable` protocol that empowers `Enum.into/2` and `Stream.into/2` and the `:into` option in comprehensions
57
* [Collectable] Implement `Collectable` for lists, dicts, bitstrings, functions and provide both `File.Stream` and `IO.Stream`
68
* [Enum] Add `Enum.group_by/2`, `Enum.into/2`, `Enum.into/3`, `Enum.traverse/2` and `Enum.sum/2`

lib/elixir/lib/base.ex

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ defmodule Base do
44
@moduledoc """
55
This module provides data encoding and decoding functions
66
according to [RFC 4648](http://tools.ietf.org/html/rfc4648).
7-
7+
88
This document defines the commonly used base 64, base 32, and base
99
16 encoding schemes.
1010
"""
11-
11+
1212
b16_alphabet = Enum.with_index '0123456789ABCDEF'
1313
b64_alphabet = Enum.with_index 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
1414
b64url_alphabet = Enum.with_index 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_'
@@ -28,7 +28,7 @@ defmodule Base do
2828
raise ArgumentError, message: "non-alphabet digit found: #{<<c>>}"
2929
end
3030
end
31-
31+
3232
@doc """
3333
Encodes a binary string into a base 16 encoded string.
3434
@@ -45,16 +45,16 @@ defmodule Base do
4545

4646
@doc """
4747
Decodes a base 16 encoded string into a binary string.
48-
48+
4949
The following alphabet is used both for encoding and decoding:
50-
50+
5151
| Value | Encoding | Value | Encoding | Value | Encoding | Value | Encoding |
5252
|------:|---------:|------:|---------:|------:|---------:|------:|---------:|
5353
| 0| 0| 4| 4| 8| 8| 12| C|
5454
| 1| 1| 5| 5| 9| 9| 13| D|
5555
| 2| 2| 6| 6| 10| A| 14| E|
5656
| 3| 3| 7| 7| 11| B| 15| F|
57-
57+
5858
## Examples
5959
6060
iex> Base.decode16("666F6F626172")
@@ -65,15 +65,15 @@ defmodule Base do
6565
def decode16(string) when is_binary(string) do
6666
{ :ok, decode16!(string) }
6767
rescue
68-
ArgumentError -> :error
68+
ArgumentError -> :error
6969
end
70-
70+
7171
@doc """
7272
Decodes a base 16 encoded string into a binary string.
73-
73+
7474
An `ArgumentError` exception is raised if the padding is incorrect or
7575
a non-alphabet character is present in the string.
76-
76+
7777
## Examples
7878
7979
iex> Base.decode16!("666F6F626172")
@@ -101,9 +101,9 @@ defmodule Base do
101101

102102
@doc """
103103
Decodes a base 64 encoded string into a binary string.
104-
104+
105105
The following alphabet is used both for encoding and decoding:
106-
106+
107107
| Value | Encoding | Value | Encoding | Value | Encoding | Value | Encoding |
108108
|------:|---------:|------:|---------:|------:|---------:|------:|---------:|
109109
| 0| A| 17| R| 34| i| 51| z|
@@ -123,7 +123,7 @@ defmodule Base do
123123
| 14| O| 31| f| 48| w| (pad)| =|
124124
| 15| P| 32| g| 49| x| | |
125125
| 16| Q| 33| h| 50| y| | |
126-
126+
127127
## Examples
128128
129129
iex> Base.decode64("Zm9vYmFy")
@@ -136,15 +136,15 @@ defmodule Base do
136136
rescue
137137
ArgumentError -> :error
138138
end
139-
139+
140140
@doc """
141141
Decodes a base 64 encoded string into a binary string.
142-
142+
143143
The following alphabet is used both for encoding and decoding:
144-
144+
145145
An `ArgumentError` exception is raised if the padding is incorrect or
146146
a non-alphabet character is present in the string.
147-
147+
148148
## Examples
149149
150150
iex> Base.decode64!("Zm9vYmFy")
@@ -164,19 +164,19 @@ defmodule Base do
164164
165165
iex> Base.url_encode64(<<255,127,254,252>>)
166166
"_3_-_A=="
167-
167+
168168
"""
169169
@spec url_encode64(binary) :: binary
170170
def url_encode64(data) when is_binary(data) do
171171
do_encode64(data, &enc64url/1)
172172
end
173-
173+
174174
@doc """
175175
Decodes a base 64 encoded string with URL and filename safe alphabet
176176
into a binary string.
177-
177+
178178
The following alphabet is used both for encoding and decoding:
179-
179+
180180
| Value | Encoding | Value | Encoding | Value | Encoding | Value | Encoding |
181181
|------:|---------:|------:|---------:|------:|---------:|------:|---------:|
182182
| 0| A| 17| R| 34| i| 51| z|
@@ -196,7 +196,7 @@ defmodule Base do
196196
| 14| O| 31| f| 48| w| (pad)| =|
197197
| 15| P| 32| g| 49| x| | |
198198
| 16| Q| 33| h| 50| y| | |
199-
199+
200200
## Examples
201201
202202
iex> Base.url_decode64("_3_-_A==")
@@ -209,14 +209,14 @@ defmodule Base do
209209
rescue
210210
ArgumentError -> :error
211211
end
212-
212+
213213
@doc """
214214
Decodes a base 64 encoded string with URL and filename safe alphabet
215215
into a binary string.
216-
216+
217217
An `ArgumentError` exception is raised if the padding is incorrect or
218218
a non-alphabet character is present in the string.
219-
219+
220220
## Examples
221221
222222
iex> Base.url_decode64!("_3_-_A==")
@@ -227,7 +227,7 @@ defmodule Base do
227227
def url_decode64!(string) when is_binary(string) do
228228
do_decode64(string, &dec64url/1)
229229
end
230-
230+
231231
@doc """
232232
Encodes a binary string into a base 32 encoded string.
233233
@@ -244,9 +244,9 @@ defmodule Base do
244244

245245
@doc """
246246
Decodes a base 32 encoded string into a binary string.
247-
247+
248248
The following alphabet is used both for encoding and decoding:
249-
249+
250250
| Value | Encoding | Value | Encoding | Value | Encoding | Value | Encoding |
251251
|------:|---------:|------:|---------:|------:|---------:|------:|---------:|
252252
| 0| A| 9| J| 18| S| 27| 3|
@@ -258,7 +258,7 @@ defmodule Base do
258258
| 6| G| 15| P| 24| Y| (pad)| =|
259259
| 7| H| 16| Q| 25| Z| | |
260260
| 8| I| 17| R| 26| 2| | |
261-
261+
262262
## Examples
263263
264264
iex> Base.decode32("MZXW6YTBOI======")
@@ -271,13 +271,13 @@ defmodule Base do
271271
rescue
272272
ArgumentError -> :error
273273
end
274-
274+
275275
@doc """
276276
Decodes a base 32 encoded string into a binary string.
277-
277+
278278
An `ArgumentError` exception is raised if the padding is incorrect or
279279
a non-alphabet character is present in the string.
280-
280+
281281
## Examples
282282
283283
iex> Base.decode32!("MZXW6YTBOI======")
@@ -288,7 +288,7 @@ defmodule Base do
288288
def decode32!(string) do
289289
do_decode32(string, &dec32/1)
290290
end
291-
291+
292292
@doc """
293293
Encodes a binary string into a base 32 encoded string with an
294294
extended hexadecimal alphabet.
@@ -305,11 +305,11 @@ defmodule Base do
305305
end
306306

307307
@doc """
308-
Decodes a base 32 encoded string with extended hexadecimal alphabet
308+
Decodes a base 32 encoded string with extended hexadecimal alphabet
309309
into a binary string.
310-
310+
311311
The following alphabet is used both for encoding and decoding:
312-
312+
313313
| Value | Encoding | Value | Encoding | Value | Encoding | Value | Encoding |
314314
|------:|---------:|------:|---------:|------:|---------:|------:|---------:|
315315
| 0| 0| 9| 9| 18| I| 27| R|
@@ -321,7 +321,7 @@ defmodule Base do
321321
| 6| 6| 15| F| 24| O| (pad)| =|
322322
| 7| 7| 16| G| 25| P| | |
323323
| 8| 8| 17| H| 26| Q| | |
324-
324+
325325
## Examples
326326
327327
iex> Base.hex_decode32("CPNMUOJ1E8======")
@@ -334,14 +334,14 @@ defmodule Base do
334334
rescue
335335
ArgumentError -> :error
336336
end
337-
337+
338338
@doc """
339-
Decodes a base 32 encoded string with extended hexadecimal alphabet
339+
Decodes a base 32 encoded string with extended hexadecimal alphabet
340340
into a binary string.
341-
341+
342342
An `ArgumentError` exception is raised if the padding is incorrect or
343343
a non-alphabet character is present in the string.
344-
344+
345345
## Examples
346346
347347
iex> Base.hex_decode32!("CPNMUOJ1E8======")
@@ -460,5 +460,5 @@ defmodule Base do
460460
defp do_decode32(_, _) do
461461
raise ArgumentError, message: "incorrect padding"
462462
end
463-
463+
464464
end

0 commit comments

Comments
 (0)