Project

General

Profile

Actions

Feature #13780

closed

String#each_grapheme

Added by rbjl (Jan Lelis) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Target version:
[ruby-core:82233]

Description

Ruby's regex engine has support for graphemes via \X:

https://github.com/k-takata/Onigmo/blob/791140951eefcf17db4e762e789eb046ea8a114c/doc/RE#L117-L124

This is really useful when working with Unicode strings. However, code like string.scan(/\X/) is not so readable enough, which might lead people to use String#each_char, when they really should split by graphemes.

What I propose is two new methods:

  • String#each_grapheme which returns an Enumerator of graphemes (in the same way like \X)

and

  • String#graphemes which returns an Array of graphemes (in the same way like \X)

What do you think?

Resources


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #18563: Add "graphemes" and "each_grapheme" aliasesClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0