In Sublime Text 2 and 3, the console output doesn\'t show the lines with accents on it:
Set the encoding of standard system output in your document to UTF-8:
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, implement the previous method as an inline command within your Python.sublime-build file.
After the encoding has been set, your document is loaded via exec within the inline 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 user copy of Python.sublime-build
Tested with Sublime Text 3 ( Stable Channel, Build 3103 ) and Python 3.4.3
How to set sys.stdout encoding in Python 3?
Alternative to execfile in Python 3?