Handle non UTF-8 characters gracefully