# HG changeset patch # User Stefan Vogel # Date 1574371387 -3600 # Node ID 92ff8a7996f986f923d20409dc1f5dbfe14579c2 # Parent 476e387608cfbded4d8d61a9b3227ec8a2b883d2 #FEATURE by stefan class: EncodedStream added: #isUnicodeEncoded #isUnicodeEncoded: diff -r 476e387608cf -r 92ff8a7996f9 EncodedStream.st --- a/EncodedStream.st Thu Nov 21 22:22:13 2019 +0100 +++ b/EncodedStream.st Thu Nov 21 22:23:07 2019 +0100 @@ -1,3 +1,5 @@ +"{ Encoding: utf8 }" + " COPYRIGHT (c) 2004 by eXept Software AG All Rights Reserved @@ -53,10 +55,10 @@ " |s| s := EncodedStream stream:Transcript encoder:(CharacterEncoder encoderToEncodeFrom:#utf8 into:#unicode). - s nextPutAll:('öäü' utf8Encoded) + s nextPutAll:('öäü' utf8Encoded) |s| - s := EncodedStream stream:('öäü' readStream) encoder:(CharacterEncoder encoderToEncodeFrom:#utf8 into:#unicode). + s := EncodedStream stream:('öäü' readStream) encoder:(CharacterEncoder encoderToEncodeFrom:#utf8 into:#unicode). s next:3 " @@ -70,7 +72,7 @@ |baseStream s| baseStream := '' readWriteStream. s := EncodedStream stream:baseStream encoding:#utf8. - s nextPutAll:'öäü'. + s nextPutAll:'öäü'. baseStream reset; contents. s contents @@ -509,6 +511,24 @@ ^ stream isReadable ! +isUnicodeEncoded + "return true, if the streamed collection is any string (8-, 16- or 32-bit), + which definitly is not using UTF-x or JIS or any other encoding. + I.e. 'self next' always returns a unicode character. + Note: the answer of false sows not mean that it is not unicode, + but it does mean that we don't know for sure." + + ^ encoder decodesToUnicode. + + "Created: / 21-11-2019 / 18:44:32 / Stefan Vogel" +! + +isUnicodeEncoded:aBoolean + "do not set - it is determined implicitly by the encoder" + + "Created: / 21-11-2019 / 18:49:08 / Stefan Vogel" +! + isWritable ^ stream isWritable ! !