diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2024-11-17 17:04:27 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2024-11-17 17:04:27 +1300 |
commit | 5edb08721c0d9a911eacaf90800c319202ade40a (patch) | |
tree | 23f1e45af95df893323522a32980500600f0be71 | |
parent | Add module docstring (diff) | |
download | vixf-5edb08721c0d9a911eacaf90800c319202ade40a.tar.gz vixf-5edb08721c0d9a911eacaf90800c319202ade40a.zip |
Set encoding explicitly from locale
-rw-r--r-- | vixf.py3 | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -7,6 +7,7 @@ edit that file with the terminal editor, and when the editor is done, read the text. """ +import locale import os import subprocess import tempfile @@ -57,7 +58,8 @@ with tempfile.NamedTemporaryFile(mode='w', delete_on_close=False) as tf: ] subprocess.run(command) - with open(tf.name, mode='r') as tfr: + encoding = locale.getpreferredencoding() + with open(tf.name, mode='r', encoding=encoding) as tfr: content = tfr.read() pyperclip.copy(content) |