Sublime Text Console Does Not Show Accent Lines

In Sublime Text 2 and 3, the console output does not display lines with accents on it:

Example

I use Tools > Build in Vanilla Sublime on Windows with an automatic build system to execute it.

Is there any fix for this?

+7
unicode sublimetext2 sublimetext utf-8 sublimetext3
source share
1 answer

Set to encode the standard system output file in the UTF-8 document:

 import sys import codecs sys.stdout = codecs.getwriter( "utf-8" )( sys.stdout.detach() ) print( "1" ) print( "áéíóúý âêîôû äëïöü àèìòù ãñõ" ) print( "2" ) 

To automatically apply UTF-8 encoded output to all documents, use the previous method as the built-in command in your Python.sublime-build file.

After the encoding has been set, your document is loaded via exec inside the built-in command .

 { "cmd": [ "python", "-u", "-c", "import sys; import codecs; sys.stdout = codecs.getwriter( 'utf-8' )( sys.stdout.detach() ); exec( compile( open( r'$file', 'rb' ).read(), r'$file', 'exec'), globals(), locals() )" ], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python", "variants": [ { "name": "Syntax Check", "shell_cmd": "python -m py_compile \"${file}\"", } ] } 

Tip. Use PackageResourceViewer to create a copy of Python.sublime-build user


Tested with Sublime Text 3 (stable channel, build 3103) and Python 3.4.3


Sources:

How to set sys.stdout encoding in Python 3?

Alternative execfile in Python 3?

+1
source share

All Articles