--- a/CharacterArray.st Wed Dec 12 15:30:09 2012 +0100
+++ b/CharacterArray.st Wed Dec 12 23:54:34 2012 +0100
@@ -326,6 +326,7 @@
"
! !
+
!CharacterArray class methodsFor:'pattern matching'!
matchEscapeCharacter
@@ -1012,12 +1013,6 @@
"
!
-isWideString
- ^ self bitsPerCharacter > 8
-
- "Created: / 05-09-2011 / 23:13:16 / cg"
-!
-
lastSpacePosition
"return the index of the last space character; 0 if there is none"
@@ -2359,11 +2354,12 @@
!
asByteArray
- |bytes sz bytesPerCharacter idx|
-
- self string ~~ self ifTrue:[
- "/ for text and other wrappers
- ^ self string asByteArray
+ |bytes sz bytesPerCharacter idx str|
+
+ str := self string.
+ str ~~ self ifTrue:[
+ "/ for text and other wrappers
+ ^ str asByteArray
].
"/ for real strings, a fallback
@@ -2372,19 +2368,19 @@
bytes := ByteArray new:(sz * bytesPerCharacter).
idx := 1.
self do:[:char |
- |code|
-
- code := char codePoint.
- bytesPerCharacter == 2 ifTrue:[
- bytes unsignedShortAt:idx put:code
- ] ifFalse:[
- bytesPerCharacter == 4 ifTrue:[
- bytes unsignedLongAt:idx put:code
- ] ifFalse:[
- bytes at:idx put:code
- ].
- ].
- idx := idx + bytesPerCharacter.
+ |code|
+
+ code := char codePoint.
+ bytesPerCharacter == 2 ifTrue:[
+ bytes unsignedShortAt:idx put:code
+ ] ifFalse:[
+ bytesPerCharacter == 4 ifTrue:[
+ bytes unsignedLongAt:idx put:code
+ ] ifFalse:[
+ bytes at:idx put:code
+ ].
+ ].
+ idx := idx + bytesPerCharacter.
].
^ bytes
@@ -2756,11 +2752,12 @@
bitsPerCharacter := newStr bitsPerCharacter.
1 to:mySize do:[:i |
- c := (self at:i) asLowercase.
- c bitsPerCharacter > bitsPerCharacter ifTrue:[
- newStr := c stringSpecies fromString:newStr.
- ].
- newStr at:i put:c
+ c := (self at:i) asLowercase.
+ (c bitsPerCharacter > bitsPerCharacter
+ and:[c stringSpecies ~= newStr stringSpecies]) ifTrue:[
+ newStr := c stringSpecies fromString:newStr.
+ ].
+ newStr at:i put:c
].
^ newStr
@@ -2881,7 +2878,7 @@
"if possible, return the receiver converted to a 'normal' string.
It is only possible, if there are no characters with codePoints above 255 in the receiver."
- self bitsPerCharacter == 8 ifTrue:[^ self].
+ self isWideString ifFalse:[^ self].
(self contains:[:char | char codePoint > 255]) ifFalse:[^ self asSingleByteString].
^ self
@@ -4314,6 +4311,7 @@
! !
+
!CharacterArray methodsFor:'padded copying'!
centerPaddedTo:newSize
@@ -4577,12 +4575,12 @@
|string max|
(string := self string) ~~ self ifTrue:[
- ^ string bitsPerCharacter
+ ^ string bitsPerCharacter
].
max := 8.
self do:[:eachCharacter |
- max := max max:(eachCharacter bitsPerCharacter)
+ max := max max:(eachCharacter bitsPerCharacter)
].
^ max
@@ -4838,6 +4836,7 @@
"Modified: 17.4.1997 / 12:50:23 / cg"
! !
+
!CharacterArray methodsFor:'special string converting'!
expandPlaceholdersWith:argArrayOrDictionary
@@ -6045,6 +6044,10 @@
"
!
+isWideString
+ ^ self bitsPerCharacter > 8
+!
+
numArgs
"treating the receiver as a message selector, return how many arguments would it take"
@@ -6123,11 +6126,11 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.481 2012-10-31 19:10:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.482 2012-12-12 22:54:34 stefan Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.481 2012-10-31 19:10:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.482 2012-12-12 22:54:34 stefan Exp $'
! !
CharacterArray initialize!