Hello. I’m using sublime text 3 for python coding. And i have some problems with cyrilic encoding.
Firstly i’ve had problems even with building(running) any file with cyrilic in it. But i’d found solution to made build config as follow:
[cmd: ['python3', '-u', '-c', "import sys; import codecs; sys.stdout = codecs.getwriter( 'utf-8' )( sys.stdout.detach() ); exec( compile( open( r'/.../ducksearch.py', 'rb' ).read(), r'/.../ducksearch.py', 'exec'), globals(), locals() )"]]
[dir: /.../crowler]
[path: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin]
So now it’s ok for me, it’s running py files with Cyrilic strings in it well. But when i’m trying to write file in cyrilic it fails again with such message:
UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' in position 197: ordinal not in range(128)
At the same time same script goes well in both python3 cmd and ipython env. So it seems that the problem is in sublime build system or in my cfg for it. So could you please tell what should i do to make it works fine?
here’s my code:
utf_8_text = html.unescape(html_entities)
print(utf_8_text)
fi = open('./tmp/tmp.html', 'w')
try:
fi.write(utf_8_text)
except Exception as e:
raise e
finally:
fi.close()
here’s some input text example (the original input is in the html entities, not cyrilyc actually).
<div class="book-description"> Культура, по мнению Ерофеева, есть дистанция между человеком, таким как он есть, и тем образом, в котором он себя видит. Неадекватность - причина смеха и слез, иронии итрагедии, определяющая ход истории, человеческое существование. В новой книге Ерофеева мир человека, культура, литература</div>