I
I
Ilyas2017-11-04 15:32:29
Python
Ilyas, 2017-11-04 15:32:29

How to create an imap folder, where the folder name is in Cyrillic?

Hello, I'm trying to create an imap folder, there are no problems with ascii characters, but if I try to use Cyrillic, then nothing happens. Python 3.5, imaplib library

M.create('INBOX.папка')

UnicodeEncodeError: 'ascii' codec can't encode characters in position 6-10: ordinal not in range(128)

M.create('INBOX.папка'.encode('utf-8'))

imaplib.error: CREATE command error: BAD [b'Error in IMAP command CREATE: 8bit data in atom (0.001 + 0.000 secs).']

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Dubrovin, 2017-11-04
@id2669099

IMAP uses UTF-7 encoding (namely 7, not 8).

A
Astrohas, 2017-11-04
@Astrohas

M.create('"INBOX.папка"')
try inside double quotes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question