Project

General

Profile

Actions

Bug #15337

closed

String#each_grapheme_cluster wrongly splits "\r\n"

Added by duerst (Martin Dürst) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.6.0dev (2018-11-24 trunk 65950) [x86_64-linux]
[ruby-core:90031]

Description

The method each_grapheme_cluster on the String class wrongly splits CRLF into two clusters, as follows:

[duerst@stazersee ruby2]$ ./ruby -e 'puts "\r\n".each_grapheme_cluster.to_a.inspect'
["\r", "\n"]
[duerst@stazersee ruby2]$ ./ruby -v
ruby 2.6.0dev (2018-11-24 trunk 65950) [x86_64-linux]

The expected result in the above case is:

["\r\n"]

Except for the test cases that contain (unpaired) surrogates, which don't apply for us, this is the only test case that fails when testing with the data at http://www.unicode.org/Public/10.0.0/ucd/auxiliary/GraphemeBreakTest.txt. I have a test script using all that data that I plan to commit as soon as this bug is dealt with.

I would like to make sure that this is correct for Unicode 10.0.0 before moving to Unicode 11.0.0. In both specifications, the CRLF case is listed explicitly first in the specification.

I will try to find out how to fix this by myself, but would definitely appreciate help.


Related issues 1 (0 open1 closed)

Blocks Ruby master - Feature #14802: Update Unicode data to Unicode Version 11.0.0Closedduerst (Martin Dürst)Actions
Actions #1

Updated by duerst (Martin Dürst) over 5 years ago

  • Blocks Feature #14802: Update Unicode data to Unicode Version 11.0.0 added
Actions #2

Updated by naruse (Yui NARUSE) over 5 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r65954.


Don't use single byte optimization on grapheme clusters

Unicode Text Segmentation considers CRLF as a character. [Bug #15337]

Updated by duerst (Martin Dürst) over 5 years ago

Once we have a fix for this bug, it should be backported to all the versions that implement \X and that we still support.

Actions #4

Updated by naruse (Yui NARUSE) over 5 years ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: DONTNEED, 2.4: REQUIRED, 2.5: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 5 years ago

  • Backport changed from 2.3: DONTNEED, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: REQUIRED, 2.5: DONE

ruby_2_5 r66073 merged revision(s) 65954,65955,65958.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0