title: Python: Which encoding is used for processing sys.argv?
body: <p>In what encoding are the elements of <code>sys.argv</code>, in Python?  are they encoded with the <code>sys.getdefaultencoding()</code> encoding?</p>
  
  <blockquote>
    <p>sys.getdefaultencoding(): Return the name of the current default string encoding used by the Unicode implementation.</p>
  </blockquote>
  
  <p><strong>PS</strong>: As pointed out in some of the answers, <code>sys.stdin.encoding</code> would indeed be a better <em>guess</em>.  I would love to see a definitive answer to this question, though, with pointers to solid sources!</p>
  
  <p><strong>PPS</strong>: As Wim pointed out, Python 3 solves this issue by putting <code>str</code> objects in sys.argv (if I understand correctly).  The question remains open for Python 2.x, though.  Under Unix, the LC_CTYPE environment variable seems to be the correct thing to check, no?  What should be done with Windows (so that sys.argv elements are correctly interpreted whatever the console)?</p>