Unicode handling:
implement #printOn: via dispatching to #nextPutAllUnicode:
resp. #nextPutAllText:
--- a/CharacterArray.st Thu Nov 06 11:59:22 2008 +0100
+++ b/CharacterArray.st Thu Nov 06 11:59:45 2008 +0100
@@ -194,26 +194,26 @@
"skip whiteSpace"
str skipSeparators.
- (str next == $') ifTrue:[
- collected := WriteStream on:(self new).
- [true] whileTrue:[
- str atEnd ifTrue:[
- "/ mhmh - reached the end without a closing quote
- "/ looks like an error to me ...
- ^ exceptionBlock value
- ].
- char := str next.
- char == $' ifTrue:[
- "/ look for another quote
- str peekOrNil == $' ifFalse:[
- ^ collected contents
- ].
- str next.
- ].
- ((char ~~ Character return) or:[str peek ~~ Character lf]) ifTrue:[
- collected nextPut:char.
- ].
- ]
+
+ (str nextOrNil == $') ifTrue:[
+ collected := self writeStream.
+ [str atEnd] whileFalse:[
+ char := str next.
+ char == $' ifTrue:[
+ "/ look for another quote
+ str peekOrNil ~~ $' ifTrue:[
+ "end of string reached"
+ ^ collected contents.
+ ].
+ "eat doubled quote"
+ str next.
+ ].
+ ((char ~~ Character return) or:[str peekOrNil ~~ Character lf]) ifTrue:[
+ "compress CRLF to LF, but keep a single CR"
+ collected nextPut:char.
+ ].
+ ].
+ "if we come here, we reached the end without finding a closing $'"
].
^ exceptionBlock value
@@ -2704,6 +2704,10 @@
'foo,bar,baz' tokensBasedOn:$,
'/etc/passwd' asFilename readStream nextLine tokensBasedOn:$:
"
+!
+
+writeStream
+ ^ CharacterWriteStream on:self
! !
!CharacterArray methodsFor:'copying'!
@@ -3100,17 +3104,12 @@
|s|
s := WriteStream on:(String uninitializedNew:self size).
- self utf8EncodedOn:s.
+ s nextPutAllUtf8:self.
^ s contents
-!
-
-utf8EncodedOn:aStream
- "append my UTF-8 representation to the argument, aStream."
-
-
- self do:[:c|
- c utf8EncodedOn:aStream.
- ].
+
+ "
+ 'abcdeäöüß' utf8Encoded
+ "
! !
!CharacterArray methodsFor:'padded copying'!
@@ -3666,21 +3665,22 @@
|s n index|
n := self occurrencesOf:$'.
- n == 0 ifFalse:[
- s := String new:(n + 2 + self size).
- s at:1 put:$'.
- index := 2.
- self do:[:thisChar |
- (thisChar == $') ifTrue:[
- s at:index put:thisChar.
- index := index + 1.
- ].
- s at:index put:thisChar.
- index := index + 1.
- ].
- s at:index put:$'.
- ^ s
+ n ~~ 0 ifTrue:[
+ s := String new:(n + 2 + self size).
+ s at:1 put:$'.
+ index := 2.
+ self do:[:thisChar |
+ (thisChar == $') ifTrue:[
+ s at:index put:thisChar.
+ index := index + 1.
+ ].
+ s at:index put:thisChar.
+ index := index + 1.
+ ].
+ s at:index put:$'.
+ ^ s
].
+
^ '''' , self , ''''
!
@@ -4215,11 +4215,8 @@
v isBlock ifTrue:[
v := v value
].
- v isString ifTrue:[
- aStream nextPutAll:v string.
- ] ifFalse:[
- v printOn:aStream.
- ]
+
+ v printOn:aStream.
].
]].
start := idx + 2
@@ -5518,7 +5515,7 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.382 2008-10-30 15:53:10 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.383 2008-11-06 10:59:45 stefan Exp $'
! !
CharacterArray initialize!