Categories
Mastering Development

Writing to txt file in UTF-8 – Python

My django application gets document from user, created some report about it, and write to txt file. The interesting problem is that everything works very well on my Mac OS. But on Windows, it can not read some letters, converts it to symbols like é, ä±. Here are my codes: views.py: def result(request): last_uploaded = […]

Categories
Mastering Development

‘utf-8’ codec can’t decode byte – Python

My Django application is working with both .txt and .doc filetypes. And this application opens a file, compares it with other files in db and prints out some report. Now the problem is that, when file type is .txt, I get ‘utf-8′ codec can’t decode byte error (here I’m using encoding=’utf-8′). When I switch encoding=’utf-8′ […]