Fixed bug in previous commit

Reverted changes to a function that I had previously tried to create,
and fixed a bug where the magical encoding character was put at the
start of the last set of values of the one type, and not at the start of
the entire string.