fix bug 1045303 - handle UTF-8 and control codes consistently

I *looks* like ```pyhs2``` is giving us ```unicode``` or ```str``` as appropriate (which earlier versions of this code did not account for), but better to be safe than sorry.