Skip to content

Commit 3d5c7b6

Browse files
committed
Fix position updates in StringIO to always use byte lengths.
1 parent cf7de9b commit 3d5c7b6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ New features:
66

77
Bug fixes:
88

9+
* Fix `StringIO` to set position correctly after reading multi-byte characters (#2207, @aardvark179).
910

1011
Compatibility:
1112

lib/truffle/stringio.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def each_byte
211211
d = @__data__
212212
string = d.string
213213

214-
while d.pos < string.length
214+
while d.pos < string.bytesize
215215
check_readable
216216
byte = string.getbyte d.pos
217217
d.pos += 1
@@ -468,7 +468,7 @@ def read(length = nil, buffer = nil)
468468
buffer.replace str if buffer
469469
end
470470

471-
d.pos += str.length
471+
d.pos += str.bytesize
472472
str
473473
end
474474

0 commit comments

Comments
 (0)