It appears that whoever changed the name of the range parameter to encode didn't rename the parameter everywhere in the function.
Changed an assert to a static assert, to cause an error at compile time rather than runtime,
Added a set of unit tests to ensure all branches of encode(E, R) get exercised.
Merge pull request #1514 from Orvid/master

Fix a set of typo's in std.encoding