Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. Iconv.iconv('asccii//translit', 'utf-8', 'Těžiště')
  2.  
  3. ActiveSupport::Multibyte::Unicode.normalize('Těžiště', :kd).chars.grep(/p{^Mn}/).join('')
  4.  
  5. > UnicodeUtils.compatibility_decomposition('Těžiště').chars.grep(/p{^Mn}/).join('')
  6. => "Teziste"
  7.  
  8. def de_accent
  9. #
  10. # `p{Mn}` is also known as `p{Nonspacing_Mark}` but only the short
  11. # and cryptic form is documented.
  12. #
  13. ActiveSupport::Multibyte::Unicode.normalize(self, :kd).chars.grep(/p{^Mn}/).join('')
  14. end
  15.  
  16. > s = 'Těžiště'.de_accent
  17. => "Teziste"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement