A
A
archmute2012-10-16 23:03:30
Python
archmute, 2012-10-16 23:03:30

Sublime Text 2 and Python 2.7: UnicodeEncodeError

OS: Windows 7 64-bit,
Just installed Sublime Text 2 and Python 2.7.
When executing this code: I get an
a = 10
print a

error:

UnicodeEncodeError: 'ascii' codec can't encode characters in position 35-39: ordinal not in range(128).

I googled that I need to change the line in the exec.py file to look like this,
proc_env[k] = os.path.expandvars(v.decode(sys.getfilesystemencoding())).encode(sys.getfilesystemencoding())
but in my case it does not help.

Nobody faced such a problem? I'm not good at programming, I wanted to figure it out.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
sergof, 2012-10-17
@sergof

Set the encoding for the BOM source
And make sure the first line in the script:
# -*- coding: UTF-8 -*-

M
mukizu, 2012-10-19
@mukizu

Are there any extensions in Sublime?

C
capau, 2012-10-20
@capau

What is the username on the system?

R
radioxoma, 2014-05-25
@radioxoma

Correct in the file `../sublime-text-2/Packages/Default/exec.py`

class ExecCommand(sublime_plugin.WindowCommand, ProcessListener):
    def run(self, cmd = [], file_regex = "", line_regex = "", working_dir = "",
            encoding = "utf-8", env = {}, quiet = False, kill = False,
            # Catches "path" and "shell"
            **kwargs):
        # Добавьте следующую строку
        cmd = [c.encode(sys.getfilesystemencoding()) for c in cmd]
        ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question