Special Characters in IMAP Folders

I was always wondering, why folders on an Exchange server, containing special characters in the name, show up that different in the IMAP protocol (e.g. using Mail::IMAPClient in Perl scripts).

But now I understand, this is just the result of the IMAP specification, that uses a modified UTF-7 encoding for non-ASCII characters (see RFC 2060, section 5.1.3).

If you ever need to automatically convert folder names into that modified UTF-7, the Perl module Encode::IMAPUTF7 may render useful.

The German Umlauts are encoded in the following way:

Umlaut IMAP-UTF-7
ä &AOQ-
ö &APY-
ü &APw-
Ä &AMQ-
Ö &ARN-
Ü &ANw-
ß &AN8-