that change I've made also contemplates problems with encodings... in this code `str()` may fail.