消息 [266062]
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". |
|
| 日期 |
用户 |
动作 |
参数 |
| 2016-05-22 09:18:54 | eryksun | 修改 | recipients:
+ 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:54 | eryksun | 修改 | messageid: <1463908734.71.0.287308006039.issue27048@psf.upfronthosting.co.za> |
| 2016-05-22 09:18:54 | eryksun | 链接 | issue27048 messages |
| 2016-05-22 09:18:54 | eryksun | 创建 | |
|