Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check for being in the middle of a codepoint when at end-of-stream (fixes #130) #131

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ensureAtBeginOfCodePointOnStream: stream
if not move further backwards. This is necessary when a position in the binary stream is set,
not knowing if that position is on a proper encoded character boundary."

"If we are at end-of-stream, we can't be in the middle of an encoded codepoint
(unless that codepoint is incomplete and thus invalid, which we won't worry about)"
stream atEnd ifTrue: [ ^ self ].
"Back up until we are not longer on a continuation byte but on a leading byte"

[ (stream peek bitAnd: 2r11000000) == 2r10000000 ] whileTrue: [ stream back ]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: #'Zinc-Character-Encoding-Core'!
self packageOrganizer ensurePackage: #'Zinc-Character-Encoding-Core' withTags: #()!
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ testUTF8ReadStreamPositioning
stream position: 5.
self assert: stream next equals: $v.
stream position: 6.
self assert: stream next equals: $e
self assert: stream next equals: $e.
stream position: 7.
self assert: stream atEnd.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: #'Zinc-Character-Encoding-Tests'!
self packageOrganizer ensurePackage: #'Zinc-Character-Encoding-Tests' withTags: #()!
Loading