aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2024-11-17 17:04:27 +1300
committerTom Ryder <tom@sanctum.geek.nz>2024-11-17 17:04:27 +1300
commit5edb08721c0d9a911eacaf90800c319202ade40a (patch)
tree23f1e45af95df893323522a32980500600f0be71
parentAdd module docstring (diff)
downloadvixf-5edb08721c0d9a911eacaf90800c319202ade40a.tar.gz
vixf-5edb08721c0d9a911eacaf90800c319202ade40a.zip
Set encoding explicitly from locale
-rw-r--r--vixf.py34
1 files changed, 3 insertions, 1 deletions
diff --git a/vixf.py3 b/vixf.py3
index a9891a8..9a9e91c 100644
--- a/vixf.py3
+++ b/vixf.py3
@@ -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)