refactor a bit, no functional changes
support replchar parameter in (currently unused) solv_replacebadutf8