Refactor the UTF-* to ASCII conversion code