Ultra7

A UTF-7 MIME header decoder, plain and simple.

What is Ultra7?

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::MIME as 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

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 © 2015, Brooke M. Fujita. All rights reserved. Please see the LICENSE file for further details.