Adds function for encoding flags along with strings.

This does not work on the JIT branch (yet).