#NEWLINE# def determine_console_encoding( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# encoding = locale . getpreferredencoding ( ) #NEWLINE# if ( ( not encoding ) or ( encoding == 'US-ASCII' ) ) : #NEWLINE# #INDENT# encoding = locale . getdefaultlocale ( ) [ 1 ] #NEWLINE# #UNINDENT# if encoding : #NEWLINE# #INDENT# codecs . lookup ( encoding ) #NEWLINE# #UNINDENT# #UNINDENT# except ( locale . Error , LookupError ) : #NEWLINE# #INDENT# encoding = None #NEWLINE# #UNINDENT# is_osx = ( sys . platform == 'darwin' ) #NEWLINE# if ( not encoding ) : #NEWLINE# #INDENT# return [ 'US-ASCII' , 'utf-8' ] [ encoding ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( encoding . startswith ( 'mac-' ) and is_osx ) : #NEWLINE# #INDENT# return 'utf-8' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return encoding