How to split string with accented characters in ruby
问题 Currently I got : "mɑ̃ʒe".split('') # => ["m", "ɑ", "̃", "ʒ", "e"] I would like to get this result "mɑ̃ʒe".split('') # => ["m", "ã", "ʒ", "e"] 回答1: Use String#each_grapheme_cluster instead. For example: "mɑ̃ʒe".each_grapheme_cluster.to_a #=> ["m", "ɑ̃", "ʒ", "e"] 来源: https://stackoverflow.com/questions/64948695/how-to-split-string-with-accented-characters-in-ruby