2

Currently I got :

"mɑ̃ʒe".split('')
# => ["m", "ɑ", "̃", "ʒ", "e"]

I would like to get this result

"mɑ̃ʒe".split('')
# => ["m", "ã", "ʒ", "e"]
Kevin
  • 65
  • 5
  • Tip: In Ruby you don't need the empty `()`. You also probably meant `split('')` or `chars`. – tadman Nov 23 '20 at 20:49

1 Answers1

6

Use String#each_grapheme_cluster instead. For example:

"mɑ̃ʒe".each_grapheme_cluster.to_a
#=> ["m", "ɑ̃", "ʒ", "e"]
Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199