Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding error #52

Open
cjunekim opened this issue Mar 7, 2016 · 1 comment
Open

encoding error #52

cjunekim opened this issue Mar 7, 2016 · 1 comment
Labels

Comments

@cjunekim
Copy link

cjunekim commented Mar 7, 2016

Hello.

Running ShellCommand on Windows with a different locale to English has encoding issues if the output of the shell command includes non-ascii characters.

Exception in thread Thread-5:
Traceback (most recent call last):
File "./threading.py", line 901, in _bootstrap_inner
File "./threading.py", line 858, in run
File "OsShell in C:\Users\user\AppData\Roaming\Sublime Text 3\Installed Packages\ShellCommand.sublime-package", line 118, in _process
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 11: invalid start byte

The problem originates from the line 118 in OsShell.py

                    output = proc.stdout.readline().decode().replace('\r\n', '\n')

The method decode() is used without encoding parameter set and the default, which is utf8, is used. If the system is not utf8 base, it causes problems. Instead, it should have been something like:

                    output = proc.stdout.readline().decode(locale.getpreferredencoding()).replace('\r\n', '\n')

Or, at least, the encoding should be changeable by configuration.

@markbirbeck
Copy link
Owner

The solution looks fair enough...I'll look at adding it.

Will need to get a Windows VM to verify it, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants