From f9621c2ed75d9ccf60c9f937f13770bc7c79c426 Mon Sep 17 00:00:00 2001 From: Andrei Kashin Date: Sat, 23 Mar 2019 11:07:16 +0000 Subject: [PATCH] [project] Add steps to debug and fix unicode errors As one of the discussions in the forum has shown, the recommendation doesn't always work on some systems. So adding instructions how to verify the solution and how to manually open files in Unicode mode. --- project/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/project/README.md b/project/README.md index a107ad1b..cd7448e3 100644 --- a/project/README.md +++ b/project/README.md @@ -16,4 +16,16 @@ export LANG=en_US.UTF-8 export LANGUAGE=en_US.UTF-8 ``` +To verify the effect, you can run the following command end check that it outputs 'utf-8' +```python +> python -c 'import locale; print(locale.getpreferredencoding())' +utf-8 +``` + You can find more details in this [article](https://perlgeek.de/en/article/set-up-a-clean-utf8-environment). + +If this doesn't work, you can explicitly specify the encoding when opening files: +```python +with open(filename, 'r', encoding="utf-8") as file: + ... +```