Module: Unaccent

Defined in:
lib/unaccent.rb,
lib/unaccent/string.rb,
lib/unaccent/version.rb

Defined Under Namespace

Modules: String

Constant Summary collapse

VERSION =
'0.3.0'

Class Method Summary collapse

Class Method Details

.unaccent(str) ⇒ String

Replace a string’s accented characters with unaccented characters.

Examples:

str = 'Å Ç ß'
Unaccent.unaccent(str) = > 'AA C ss'

Returns:

  • (String)

    a string that has no accents



17
18
19
20
21
# File 'lib/unaccent.rb', line 17

def unaccent(str)
  return str if str.ascii_only?

  str.gsub(/[^[:ascii:]]/) { |char| ACCENTMAP.fetch(char, char) }
end