mirror of
https://github.com/wting/autojump
synced 2026-03-02 03:49:26 +00:00
Fix encoding issues.
The original implementation used str.encode() on input and str.decode() on output. However this would cause UnicodeDecodeError since certain characters can't be encoded / decoded in ASCII. The new solution is to use unicode() on all input strings and output UTF-8 encoded strings. This makes the assumption that the shell can handle UTF-8 strings.
This commit is contained in:
@@ -17,6 +17,7 @@ else:
|
||||
from itertools import imap
|
||||
|
||||
from autojump_utils import create_dir
|
||||
from autojump_utils import unico
|
||||
from autojump_utils import is_osx
|
||||
from autojump_utils import is_python3
|
||||
from autojump_utils import move_file
|
||||
@@ -124,11 +125,7 @@ def save(config, data):
|
||||
encoding='utf-8',
|
||||
errors='replace') as f:
|
||||
for path, weight in data.items():
|
||||
if is_python3():
|
||||
f.write(("%s\t%s\n" % (weight, path)))
|
||||
else:
|
||||
f.write(unicode(
|
||||
"%s\t%s\n" % (weight, path)).encode('utf-8'))
|
||||
f.write(unico("%s\t%s\n" % (weight, path)))
|
||||
|
||||
f.flush()
|
||||
os.fsync(f)
|
||||
|
||||
Reference in New Issue
Block a user