Question:
This one is a challenge. Seems GMAIL allows for some damn crazy mailbox values, as such I've been working on properly escaping the string values used by Gmail.
Here's an example:
AnyCharsWeCan'tUse?!@#$%&*()_+{}|[]\;:'"
So we escape this properly (as per IMAP RFC):
AnyCharsWeCan'tUse?!@#$%&*()_+{}|[]\;:'"
And use ExamineMailbox..
It fails, so I pull the session log and see:
----IMAP REQUEST---- aaaq EXAMINE "AnyCharsWeCan&AFw-'tUse?!@#$%&-*()_+{}|[]&AFwAXA-;:&AFw-'&AFw-"" ----IMAP RESPONSE---- aaaq BAD Could not parse command
Any idea what is going on here?
hz
Ok, I've done a lot more digging, here's what I've uncovered.
First I switched everything to the Unicode version, just to avoid any ANSI/Utf8 mis-calculations. Next, I opened up Thunderbird and dumped the entire IMAP traffic, I noticed it was issuing the following:
select "AnyCharsWeCan'tUse?!@#$%&-*()_+{}|[]\;:'""
The key there is the "dash" value. When I run the same command (SelectMailbox) using the unicode output of ListMailboxes I get the following in the Session Log.
SELECT "AnyCharsWeCan'tUse?!@#$%&*()_+{}|[]\;:'""
Notice the "-" is gone? GMAIL returns that this is an invalid UTf7 string..
So I go back to ListMailboxes and dump the Session log immediately upon completion.
----IMAP RESPONSE----
So I'm getting good values from the ListMailboxes, however I'm not getting that same value when I iterate through the CkMailboxesW object. Calling ->getName(i) gives me a wchar_t * that is missing the "-" value.
Any ideas?
-hz
You shouldn't need to escape any chars in the mailbox name -- other than possibly escaping characters according to the syntax of a given programming language when it comes to literal strings. In the IMAP protocol, the mailbox names are encoded to utf-7 as per the IMAP protocol specification. (It's not exactly utf-7, because the IMAP protocol defines a few differences, and Chilkat adheres to the IMAP specifications.) Also, there should be no need to worry about ANSI/utf-8/Unicode. As long as you're passing the string correctly, then Chilkat automatically handles any necessary conversions (from ANSI, or utf-8, or Unicode) to the utf-7 required.