All Questions
65 questions
3
votes
0
answers
34
views
how does python determine encodings under different circumstances? [duplicate]
I have a python script that runs on a windows machine and looks like this:
print(f"Current encoding: {sys.stdout.encoding}")
print(some_randomized_chars)
and I run it in different ways ...
1
vote
1
answer
287
views
Why do Backspace and Ctrl + Backspace produce different bytestrings within Linux and Windows, and how can this discrepancy be resolved within my code?
I am working on a typing game in Python that uses getch() to read in characters, then performs different actions depending on which character has been entered.
The code for reading in characters and ...
1
vote
1
answer
904
views
How do I get UTF-8 to work flawlessly in modern PowerShell on Windows?
I have a C++ program which outputs raw UTF-8 and works flawlessly on Linux, but on Windows shells the output is not as nice. "®" turns into "┬«", "©" turns into "┬⌐&...
5
votes
1
answer
688
views
Python subprocess Popen set encoding of the child process
This SSCCE reports the encoding rule on sys.stdout. It works by creating a temporary Python file and running it via the subprocess module:
subp_code = "import sys\nprint(sys.stdout.encoding)"...
2
votes
0
answers
80
views
Why do non-latin characters in Windows 10 path look wrong?
In my Python app on Windows 10 I use following code:
gettempdir() + os.sep + 'storage.json'
It returns "C:\Users\3EC2~1\AppData\Local\Temp\storage.json", yet I expect "Антон" ...
1
vote
2
answers
725
views
Wrong encoding when redirecting printed unicode characters on Windows PowerShell
Using python 3, running the following code
print("some box drawing:")
print("┌─┬┼┴┐")
via
py my_app.py
prints
some box drawing:
┌─┬┼┴┐
As you would expect.
However, if you ...
3
votes
1
answer
197
views
Python str vs unicode on Windows, Python 2.7, why does 'á' become '\xa0'
Background
I'm using a Windows machine. I know Python 2.* is not supported anymore, but I'm still learning Python 2.7.16. I also have Python 3.7.1. I know in Python 3.* "unicode was renamed to ...
0
votes
2
answers
63
views
How to properly define a windows foldername to be used with python?
I have the following small code snippet in python 3.10 on windows 10 powershell
win_folder = b"C:\Program Files (x86)\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin"
os.chdir(...
0
votes
1
answer
260
views
cURL automatically replacing alternates to functional characters with underscore?
In installing and utilizing cURL (specifically curl 7.86.0 (Windows) libcurl/7.86.0; previously I said it was curl 7.83.1 (Windows) libcurl/7.83.1 but I was mistaken) to download .htm files in ...
0
votes
0
answers
384
views
Wrong default system encoding detected in Java application
What is the problem?
I've noticed a strange problem with Java showing different default file encodings while running at the same machine and OS (Windows 10). If I run my Gradle application from a ...
0
votes
1
answer
358
views
Pycharm adding mandatory BOM when creating files from terminal [duplicate]
After I updated Pycharm to version 2021.2, whenever I create a new .py file on Pycharm terminal with echo, I can't run it because of the following error:
SyntaxError: Non-UTF-8 code starting with '\...
1
vote
2
answers
3k
views
How to get subprocess output and maintain encoding
I am most likely missing some really easy, but I can't wrap my head around why what seems to work for everyone else doesnt work for me.
Goal: I want to run shell commands with native output in non-...
0
votes
2
answers
518
views
INI file doesn't work. It has an extra '・' at the very beggining. Why?
This is a part of an ini file someone wrote.
It looks perfect, but python won't read it properly.
I read it via Python and happened to find '・' at the very first line, which shouldn't be here.
Like ...
3
votes
1
answer
5k
views
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 73776
This is a Django project.
Encountering error upon running pip install -r requirements.txt in a local virtualenv.
Collecting https://github.com/jedestep/Zappa/archive/layer-support.zip (from -r ...
3
votes
2
answers
4k
views
Why does Python 3 read a file with encoding cp1252 by default?
When doing:
with open('test.txt', 'r') as f:
print(f)
I get:
<_io.TextIOWrapper name='test.txt' mode='r' encoding='cp1252'>
Why is it cp1252 by default? The test.txt has been saved with UTF8 ...