Sublime Forum

[ST3] getpreferredencoding

#1

I have some problems regarding utf8 decoding in some pluglins (modific, rsub, …).
When the plugin read a file or a socket show a error like:
raceback (most recent call last):
File “X/socketserver.py”, line 610, in process_request_thread
File “X/socketserver.py”, line 345, in finish_request
File “X/socketserver.py”, line 666, in init
File “/Users/sbarex/Library/Application Support/Sublime Text 3/Packages/rsub/rsub.py”, line 143, in handle
line = socket_fd.readline()
File “X/encodings/ascii.py”, line 26, in decode
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 1836: ordinal not in range(128)

in the console I type:
import locale
locale.getpreferredencoding()

the output is ‘US-ASCII’ and not ‘utf-8’.
I think this is the problem but I don’t know how resolve it.

I’m on OSX 10.8.
thanks

0 Likes

#2

I’ve just had a similar problem (with BBEdit), where my Python locale’s preferred encoding was also US-ASCII.

The solution was to explicitly set LANG in my ~/.bash_profile.
As a British English user, it reads: export LANG=“en_GB.UTF-8”

For safety, I’ve also included that line in ~/.bashrc (as non-login shells don’t read .bash_profile).

0 Likes