Ultra7
A UTF-7 MIME header decoder, plain and simple.
What is Ultra7?
- Ultra7 is a UTF-7 decoder for MIME message headers, per the MIME encoded word syntax of RFC-2047.
- It is almost, but not quite, completely unlike
Net::IMAP.decode_utf7, which is meant for decoding mailbox names. Ultra7 only does MIME message headers. Ultra7::MIMEis also a mixin, so you can conveniently combine it in another class by usinginclude.- Read the API documentation.
- Learn more about Ultra7 at GitHub.
Requirements
- Ultra7 does not really require anything, except a Ruby of 1.9 or greater.
Installation
Install Ultra7 with the following gem command:
gem install ultra7
Usage
Using Ultra7 is pretty straight-forward, really. It only decodes UTF-7.
require 'ultra7' # just call decode_utf7 puts Ultra7::MIME.decode_utf7('1 +- 1 = 2') => "1 + 1 = 2" # Decodes UTF-7, returning string with default encoding puts Ultra7::MIME.decode_utf7('Hello, +ZeVnLIqe-') => "Hello, 日本語" # Decodes an actual Subject MIME header in UTF-7, # returning string with explicit UTF-8 encoding subject = '=?unicode-1-1-utf-7?Q?+vDCy7A- +wMHQ3A- +xUy5vA-(+wuTTKA-)?=' Ultra7::MIME.decode_utf7(subject, encoding: 'UTF-8') => "배달 상태 알림(실패)"And you can use
Ultra7::MIMEas a mixin.# As a mixin to another class require 'ultra7/mime' class Foo include Ultra7::MIME end puts Foo.decode_utf7('Hi Mom -+Jjo--!') => "Hi Mom -☺-!"
Learn more
- You can read more about UTF-7, A Mail-Safe Transformation Format of Unicode RFC2152.
- Contrast with
Net::IMAP.decode_utf7.
Contributing to Ultra7
- Use git and check out the latest code at GitHub to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
- Browse the issue tracker to make sure someone already hasn't requested it and/or contributed it.
- Fork the project.
- Start a feature/bugfix branch.
- Commit and push until you are happy with your contribution.
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally. I use MiniTest::Unit as it is very natural and easy-to-use.
- Please try not to mess with the Rakefile, CHANGELOG, or version. If you must have your own version, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Changelog
Please see the CHANGELOG for this gem's release history.
Copyright
Copyright © 2015, Brooke M. Fujita. All rights reserved. Please see the LICENSE file for further details.