Class: Picky::Vietnamese::Substituter
- Inherits:
-
CharacterSubstituters::Base
- Object
- CharacterSubstituters::Base
- Picky::Vietnamese::Substituter
- Defined in:
- lib/picky-vietnamese.rb
Instance Method Summary collapse
Instance Method Details
#substitute(text) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/picky-vietnamese.rb', line 7 def substitute text #http://rishida.net/scripts/pickers/vietnamese/ #http://vietunicode.sourceforge.net/main.html #ăaăâeêioôơuưy ắ ớ ố ộ ợ ệ ị ụ ỉ result = []; text.downcase.mb_chars.normalize(:kd).unpack('U*').map{|c| case c when 0..127 result << c when 0x103 #A( result << 97 when 0xE2 #A^ result << 97 when 0xEA #E^ result << 101 when 0xF4 #o^ result << 111 when 0x1A1 #O* result << 111 when 0x1B0 #U* result << 117 when 0x111 #dd result << 100 end } result.pack('U*') end |