SHARE
TWEET

Untitled

a guest Jun 20th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top