Skip to content

Commit 6deb924

Browse files
committed
Fix String#lines for multibyte characters
1 parent 8d04a12 commit 6deb924

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 1.0 RC 12
2+
3+
Bug fixes:
4+
5+
* Fixed a bug with `String#lines` and similar methods with multibyte
6+
characters (#1543).
7+
18
# 1.0 RC 11
29

310
New features:

spec/tags/core/string/each_line_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/tags/core/string/lines_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/ruby/core/string.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ def each_line(sep=$/, chomp: false)
934934
sep = "\n\n"
935935
data = bytes
936936

937-
while pos < size
937+
while pos < bytesize
938938
nxt = Truffle.invoke_primitive(:find_string, self, sep, pos)
939939
break unless nxt
940940

@@ -964,10 +964,10 @@ def each_line(sep=$/, chomp: false)
964964
else
965965

966966
# This is the normal case.
967-
pat_size = sep.size
967+
pat_size = sep.bytesize
968968
unmodified_self = clone
969969

970-
while pos < size
970+
while pos < bytesize
971971
nxt = Truffle.invoke_primitive(:find_string, unmodified_self, sep, pos)
972972
break unless nxt
973973

0 commit comments

Comments
 (0)