module WithoutAccents
RemoveAccents version 1.0.3 © 2008-2009 Solutions Informatiques Techniconseils inc.
This module adds 2 methods to the string class. Up-to-date version and documentation available at:
www.techniconseils.ca/en/scripts-remove-accents-ruby.php
This script is available under the following license : Creative Commons Attribution-Share Alike 2.5.
See full license and details at : creativecommons.org/licenses/by-sa/2.5/ca/
Version history:
* 1.0.3 : July 23 2009 Corrected some incorrect character codes. Source is now wikipedia at: http://en.wikipedia.org/wiki/ISO/IEC_8859-1#Related_character_maps Thanks to Raimon Fernandez for pointing out the incorrect codes. * 1.0.2 : October 29 2008 Slightly optimized version of urlize - Jonathan Grenier (jgrenier@techniconseils.ca) * 1.0.1 : October 29 2008 First public revision - Jonathan Grenier (jgrenier@techniconseils.ca)
Constants
- ACCENTS_MAPPING
The extended characters map used by removeaccents. The accented characters are coded here using their numerical equivalent to sidestep encoding issues. These correspond to ISO-8859-1 encoding.
- ACCENTS_MAPPING_REGEXPS
Public Instance Methods
without_accents()
click to toggle source
Remove the accents from the string. Uses String::ACCENTS_MAPPING as the source map.
# File lib/core-extensions/string_without_accents.rb, line 64 def without_accents str = String.new(self) ACCENTS_MAPPING_REGEXPS.each {|letter,regexp| str.gsub!(regexp, letter) } str end