Linked Questions

23 questions linked to/from UnicodeDecodeError when redirecting to file
183 votes
16 answers
142k views

When I try to print a string in a Windows console, sometimes I get an error that says UnicodeEncodeError: 'charmap' codec can't encode character ..... I assume this is because the Windows console ...
James Sulak's user avatar
  • 32.7k
89 votes
7 answers
81k views

Setting the default output encoding in Python 2 is a well-known idiom: sys.stdout = codecs.getwriter("utf-8")(sys.stdout) This wraps the sys.stdout object in a codec writer that encodes output in UTF-...
56 votes
4 answers
39k views

Any thoughts on why this isn't working? I really thought 'ignore' would do the right thing. >>> 'add \x93Monitoring\x93 to list '.encode('latin-1','ignore') Traceback (most recent call last)...
Greg's user avatar
  • 47.5k
35 votes
4 answers
116k views

I am using pyserial and need to send some values less than 255. If I send the int itself the the ascii value of the int gets sent. So now I am converting the int into a unicode value and sending it ...
21 votes
4 answers
21k views

I'm using Windows and Linux machines for the same project. The default encoding for stdin on Windows is cp1252, and on Linux it is utf-8. I would like to change everything to utf-8. Is it possible? ...
3 votes
3 answers
5k views

Can someone explain to me why python has this behaviour? Let's me explain. BACKGROUND I have a python installation and I want to use some chars that aren't in the ASCII table. So I change my python ...
8 votes
6 answers
6k views

I'm trying to write the symbol くろまる to a text file in python. I think it has something to do with the encoding (utf-8). Here is the code: # -*- coding: utf-8 -*- outFile = open('./myFile.txt', 'wb') ...
2 votes
4 answers
13k views

For the past few days I've been learning programing with Python and I'm still but a beginner. Recently, I've used the book 'Code in the cloud' for that purpose. The thing is, while all those textbooks ...
1 vote
1 answer
7k views

I was trying to get data from the website and input it into csv table_array = [] def get_data(page): url = "https://www.sl886.com/stockrating/list?list=stockrating&page=" + str(page)...
KickAxe's user avatar
  • 149
7 votes
2 answers
2k views

When I try to redirect a UTF-8 stdout in Powershell by running python3 .\test.py > test.txt, error occurs : UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1: character ...
-1 votes
1 answer
5k views

I'm new to python and face a strange problem: When I have 50 txt files in a directory, I want to read each .txt file and save its content in a unique variable like: **file = open(fcf[i], 'r') text[i]...
0 votes
1 answer
2k views

I retrieved a bunch of text records from my postgresql database and intend to preprocess these text documents before analyzing them. I want to tokenize the documents but ran into some problem during ...
goh's user avatar
  • 29.9k
5 votes
3 answers
1k views

What I want to do: extract text information from a pdf file and redirect that to a txt file. What I did: pip install pdfminor pdf2txt.py file.pdf > output.txt What I got: UnicodeEncodeError: '...
1 vote
2 answers
2k views

I am using an API in Python v2.7 to obtain a string, the content of which is unknown. The content can be in English, German or French. The variable name assigned to the returned string is 'category'. ...
0 votes
1 answer
1k views

This is a script that sends randomly generated sentences into a discord chat. But it occasionally runs into the error: UnicodeDecodeError: 'ascii' codec cant decode byte 0xef in position 2141: ...
Museman's user avatar

15 30 50 per page
1
2