Project

unaccent

0.36
No commit activity in last 3 years
No release in over 3 years
Replace accented characters with unaccented characters.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 2.0
~> 5.0
~> 13.0
 Project Readme

Unaccent

Ruby gem to replace a string's accent characters with unaccented characters. Based on SixArm Ruby Unaccent.

Gem Version Build Maintainability

Installation

Add this line to your application's Gemfile:

gem 'unaccent'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install unaccent

Usage

require 'unaccent'

Unaccent.unaccent('déjà vu') # deja vu
Unaccent.unaccent('νέα')     # νεα

require 'unaccent/string'

'déjà vu'.unaccent # deja vu
'νέα'.unaccent     # νεα

Benchmark

Warming up --------------------------------------
            unaccent     3.259k i/100ms
              sixarm   838.000  i/100ms
Calculating -------------------------------------
            unaccent     32.573k (± 2.1%) i/s -    162.950k in   5.004780s
              sixarm      8.025k (± 4.6%) i/s -     40.224k in   5.023339s

Comparison:
            unaccent:    32573.1 i/s
              sixarm:     8024.7 i/s - 4.06x  (± 0.00) slower

Calculating -------------------------------------
            unaccent     5.947k memsize (     0.000  retained)
                        76.000  objects (     0.000  retained)
                        42.000  strings (     0.000  retained)
              sixarm    29.979k memsize (     0.000  retained)
                       633.000  objects (     0.000  retained)
                        50.000  strings (     0.000  retained)

Comparison:
            unaccent:       5947 allocated
              sixarm:      29979 allocated - 5.04x more

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hardpixel/unaccent.

License

The gem is available as open source under the terms of the MIT License.