This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients abarry, dstufft, eric.araujo, eryksun, ezio.melotti, martin.panter, paul.moore, r.david.murray, steve.dower, tim.golden, vstinner, zach.ware
Date 2016-05-22.09:18:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1463908734.71.0.287308006039.issue27048@psf.upfronthosting.co.za>
In-reply-to
Content
When writing to a file or pipe, cmd's internal commands default to either the current codepage of the attached console or, for a detached process, the system locale codepage. It uses a best-fit encoding that tries to map characters to similar characters in the codepage. For example:

    >>> win_unicode_console.enable()
    >>> os.environ['TEST©'] = '®'
    >>> out = subprocess.check_output('cmd /c set test')
    >>> out.decode(sys.__stdout__.encoding).strip()
    'TESTc=r'

You can force it to use Unicode (UTF-16LE) with the /u option:

    >>> out = subprocess.check_output('cmd /u /c set test')
    >>> out.decode('utf-16le').strip()
    'TEST©=®'

subprocess could use "/u /c" instead of "/c". This would only affect the output of internal shell commands such as "dir" and "set".
History
Date User Action Args
2016-05-22 09:18:54eryksunsetrecipients: + eryksun, paul.moore, vstinner, tim.golden, ezio.melotti, eric.araujo, r.david.murray, martin.panter, zach.ware, steve.dower, dstufft, abarry
2016-05-22 09:18:54eryksunsetmessageid: <1463908734.71.0.287308006039.issue27048@psf.upfronthosting.co.za>
2016-05-22 09:18:54eryksunlinkissue27048 messages
2016-05-22 09:18:54eryksuncreate