如何在 ruby 中用重音字符拆分字符串

How to split string with accented characters in ruby

目前我得到了:

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

我想得到这个结果

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

改用String#each_grapheme_cluster。例如:

"mɑ̃ʒe".each_grapheme_cluster.to_a
#=> ["m", "ɑ̃", "ʒ", "e"]