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.

Title: IDLE 2.7 should use UTF-8 as it's default encoding
Type: behavior Stage: resolved
Components: IDLE Versions: Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder: 2.7 IDLE console uses incorrect encoding.
View: 15809
Assigned To: Nosy List: THRlWiTi, matrixise, serhiy.storchaka, terry.reedy
Priority: normal Keywords:

Created on 2013-11-16 14:53 by THRlWiTi, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg203047 - (view) Author: Thrlwiti (THRlWiTi) * Date: 2013-11-16 14:53
>>> s = 'ی'
Unsupported characters in input

I'm using windows 8 and Python 2.7.6.

The same line works perfectly if I save it in a module with encoding set to UTF-8; but it's really annoying that I can't test my code directly in IDLE.
msg203058 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-11-16 16:13
This is a duplicate of issue15809.
msg218569 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2014-05-14 19:39
For the benefit of anyone finding this in a search, I fixed the title to match the actual request.  UTF-8 *is* already the default encoding in 3.x, and upgrading to 3.x if at all possible is the best solution to unicode problems.
msg242224 - (view) Author: Thrlwiti (THRlWiTi) * Date: 2015-04-29 13:59
Although in Python 3 IDLE can indeed print UTF-8 characters. But still sys.stdout.encoding == locale.getpreferredencoding() != 'utf-8'.

>>> sys.stdout.encoding

Shouldn't it be 'utf-8'?
msg242225 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2015-04-29 14:04
On OS X and with IDLE 3, I get utf-8 with sys.stdout.encoding, not sure, 
but I think you have to check the default encoding on Windows.

What’s the result if you execute:

python3 -c 'import sys; print(sys.getdefaultencoding())'
msg242229 - (view) Author: Thrlwiti (THRlWiTi) * Date: 2015-04-29 14:35
On cmd and powershell:

>python -c "import sys; print(sys.getdefaultencoding());"
>python -c "import sys; print(sys.stdout.encoding);"

>>> import sys; print(sys.getdefaultencoding());
>>> sys.stdout.encoding
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63824
2015-04-29 14:35:06THRlWiTisetmessages: + msg242229
2015-04-29 14:04:21matrixisesetnosy: + matrixise
messages: + msg242225
2015-04-29 13:59:04THRlWiTisetmessages: + msg242224
2014-05-14 19:39:55terry.reedysetnosy: + terry.reedy

messages: + msg218569
title: IDLE should use UTF-8 as it's default encoding -> IDLE 2.7 should use UTF-8 as it's default encoding
2013-11-16 16:13:21serhiy.storchakasetstatus: open -> closed

superseder: 2.7 IDLE console uses incorrect encoding.
nosy: + serhiy.storchaka

messages: + msg203058
type: behavior
resolution: duplicate
stage: resolved
2013-11-16 14:53:51THRlWiTicreate