Check for and handle non-utf-8-encoded input.

As discussed in our email thread. Current workaround in master fails if input is *already* utf-8-encoded, non-ascii text.