#BUGFIX by stefan
class: EncodedStream
changed: #position
fix #position after doing a peek
--- a/EncodedStream.st Mon Jan 15 08:31:33 2018 +0100
+++ b/EncodedStream.st Mon Jan 15 22:25:56 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 2004 by eXept Software AG
All Rights Reserved
@@ -53,7 +55,7 @@
"
|s|
s := EncodedStream stream:Transcript encoder:(CharacterEncoder encoderToEncodeFrom:#utf8 into:#unicode).
- s nextPutAll:('öäü' utf8Encoded)
+ s nextPutAll:('öäü' utf8Encoded)
"
!
@@ -64,7 +66,7 @@
|baseStream s|
baseStream := '' readWriteStream.
s := EncodedStream stream:baseStream encoding:#utf8.
- s nextPutAll:'öäü'.
+ s nextPutAll:'öäü'.
baseStream reset; contents.
"
! !
@@ -357,9 +359,16 @@
"only use #position/#position: to restore a previous position.
Computing relative positions does not work!!"
- ^ stream position
+ |pos|
- "Modified (comment): / 09-01-2018 / 17:49:55 / stefan"
+ pos := stream position.
+ peekChar notNil ifTrue:[
+ "#position: nils peekChar - make sure, that it positions before peekChar"
+ pos := pos - peekChar utf8BytesPerCharacter.
+ ].
+ ^ pos.
+
+ "Modified (format): / 15-01-2018 / 22:25:03 / stefan"
!
position0Based