Support for charset
ehlyzov opened this issue · 0 comments
ehlyzov commented
If I use search options which are not 'ascii-8bit' encoded, server response is:
[1] pry(main)> mailbox.inbox.emails(gm: 'Привет из Питера!')
Encoding::CompatibilityError: incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)
String#force_encoding can be used, but in this case Gmail must be aware of original encoding. Otherwise it response with Net::IMAP::BadResponseError: Could not parse command
So I patched Mailbox#emails (master...ehlyzov:master#diff-41778eca41b3a50379aa723a35b177db) but I don't sure if opts
is a good place for charset configuration. Maybe it is better to create the mailbox attribute. What do you think?
Anyway, with this change following code looks clumsy, but it works:
mailbox.inbox.emails(gm: 'Привет из Питера!'.force_encoding('ascii-8bit'), charset: 'UTF-8')
Probably it would be better to make this default behaviour, can't imagine any drawbacks.