I use a 3rd party tool that outputs a file in Unicode format. However, I prefer it to be in ASCII. The tool does not have settings to change the file format.
What is the best way to convert the entire file format using Python?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can convert the file easily enough just using the
unicodefunction, but you’ll run into problems with Unicode characters without a straight ASCII equivalent.This blog recommends the
unicodedatamodule, which seems to take care of roughly converting characters without direct corresponding ASCII values, e.g.is typically converted to
which is pretty wrong. However, using the
unicodedatamodule, the result can be much closer to the original text: