0

I am acquiring a list of folders from an email account, some of these have chinese characters. However the output from Ruby, is not proper. How do I get it display the correct characters?

Example:

"Group: &gC9UCE6SUtVQs2StgKFO,WcJllBRbFP4-" 

The group of obscure characters is actually a list of chinese characters.

I have tried switching the encoding to utf-8. However that results in the same thing.

I have even used the force_encoding method on the string, yet same result.

Nakilon
  • 34,866
  • 14
  • 107
  • 142
ShivamD
  • 931
  • 10
  • 21
  • This is 'modified UTF-7 encoding', used for IMAP folders. Look to see if your IMAP library has a decoding function for folder names. – Max Dec 21 '14 at 01:57

1 Answers1

3

Try Net::IMAP.decode_utf7:

Net::IMAP.decode_utf7('&gC9UCE6SUtVQs2StgKFO,WcJllBRbFP4-')
=> "耯合互動傳播股份有限公司"
Casper
  • 33,403
  • 4
  • 84
  • 79