class: Array
changed: #printOn:
Use CharacterWriteStream for Unicode compatibility
--- a/Array.st Wed Apr 22 18:05:16 2015 +0200
+++ b/Array.st Wed Apr 22 19:27:19 2015 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -301,7 +303,6 @@
"Modified: 23.4.1996 / 15:55:06 / cg"
! !
-
!Array methodsFor:'accessing'!
at:index
@@ -1742,54 +1743,54 @@
"append a printed representation of the receiver to aStream"
self isLiteral ifTrue:[
- |limit firstOne s|
+ |limit firstOne s|
- thisContext isRecursive ifTrue:[
- 'Array [error]: printOn: of self referencing collection.' errorPrintCR.
- aStream nextPutAll:'#("recursive")'.
- ^ self
- ].
+ thisContext isRecursive ifTrue:[
+ 'Array [error]: printOn: of self referencing collection.' errorPrintCR.
+ aStream nextPutAll:'#("recursive")'.
+ ^ self
+ ].
- aStream nextPutAll:'#('.
- firstOne := true.
+ aStream nextPutAll:'#('.
+ firstOne := true.
- "
- if aStream is not positionable, create an temporary positionable stream
- (needed for limit calculation)
- "
- aStream isPositionable ifTrue:[
- s := aStream.
- ] ifFalse:[
- s := WriteStream on:(String uninitializedNew:50).
- ].
- limit := s position + self maxPrint.
+ "
+ if aStream is not positionable, create an temporary positionable stream
+ (needed for limit calculation)
+ "
+ aStream isPositionable ifTrue:[
+ s := aStream.
+ ] ifFalse:[
+ s := CharacterWriteStream new:50.
+ ].
+ limit := s position + self maxPrint.
- self printElementsDo:[:element |
- firstOne ifFalse:[
- s space
- ] ifTrue:[
- firstOne := false
- ].
- (s position >= limit) ifTrue:[
- s ~~ aStream ifTrue:[
- aStream nextPutAll:(s contents).
- ].
- aStream nextPutAll:'...etc...)'.
- ^ self
- ] ifFalse:[
- element printOn:s.
- ].
- ].
- s ~~ aStream ifTrue:[
- aStream nextPutAll:(s contents).
- ].
- aStream nextPut:$)
+ self printElementsDo:[:element |
+ firstOne ifFalse:[
+ s space
+ ] ifTrue:[
+ firstOne := false
+ ].
+ (s position >= limit) ifTrue:[
+ s ~~ aStream ifTrue:[
+ aStream nextPutAll:(s contents).
+ ].
+ aStream nextPutAll:'...etc...)'.
+ ^ self
+ ] ifFalse:[
+ element printOn:s.
+ ].
+ ].
+ s ~~ aStream ifTrue:[
+ aStream nextPutAll:(s contents).
+ ].
+ aStream nextPut:$)
] ifFalse:[
- super printOn:aStream
+ super printOn:aStream
]
"
- #(1 2 $a 'hello' sym kewordSymbol:with: #'funny symbol') printString
+ #(1 2 $a $Š 'hello' sym kewordSymbol:with: #'funny symbol') printString
#(1 2 $a [1 2 3] true false nil #true #false #nil) printString
"
@@ -2641,9 +2642,10 @@
!Array class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.166 2015-04-20 14:04:23 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.167 2015-04-22 17:27:19 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.166 2015-04-20 14:04:23 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Array.st,v 1.167 2015-04-22 17:27:19 stefan Exp $'
! !
+