Add method to test to produce properly-encoded string for regex method.

This ensures that we've got a valid string to work with, no matter the
encoding.