Use `chars` instead of `split`
Raise when trying to encode negative numbers
Use `prepend` to avoid creating new string objects
No need to create separate variable