For some reason I left a 377KiB test case checked in. Replacing this with a generated test case is obvious in hindsight.
Finally got off my butt and started using EUnit.
There was a bug that was resetting the extra amount of space needed when encoding unicode characters with the `uescape` option enabled.