Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v2.1.0
Fetching contributors…

Cannot retrieve contributors at this time

37 lines (30 sloc) 0.702 kb
# encoding: utf-8
#
module CharacterSubstituters # :nodoc:all
# Substitutes Umlauts like
# ä, ö, ü => ae, oe, ue.
# (and more, see specs)
#
class WestEuropean
def initialize
@chars = ActiveSupport::Multibyte.proxy_class
end
def to_s
self.class.name
end
def substitute text
trans = @chars.new(text).normalize(:kd)
# substitute special cases
#
trans.gsub!('ß', 'ss')
# substitute umlauts (of A,O,U,a,o,u)
#
trans.gsub!(/([AOUaou])\314\210/u, '\1e')
# get rid of ecutes, graves and …
#
trans.unpack('U*').select { |cp|
cp < 0x0300 || cp > 0x035F
}.pack('U*')
end
end
end
Jump to Line
Something went wrong with that request. Please try again.