--- a/CharacterArray.st Mon Oct 29 17:05:17 2012 +0000
+++ b/CharacterArray.st Mon Oct 29 22:07:56 2012 +0000
@@ -868,6 +868,8 @@
!
asWideString
+ "return a two-byte string containing the same characters as the receiver"
+
^ self asTwoByteString
"
@@ -876,6 +878,8 @@
!
capitalized
+ "same as asUppercaseFirst for Squeak compatibility"
+
^ self asUppercaseFirst
"
@@ -892,15 +896,17 @@
!
charactersExactlyMatching:aString
+ "return the number of characters I share as a prefix with the argument, aString"
+
|idx nMax|
nMax :=(self size) min:(aString size).
idx := 1.
[idx <= nMax] whileTrue:[
- (self at:idx) = (aString at:idx) ifFalse:[
- ^ idx - 1
- ].
- idx := idx + 1.
+ (self at:idx) = (aString at:idx) ifFalse:[
+ ^ idx - 1
+ ].
+ idx := idx + 1.
].
^ nMax
@@ -1012,6 +1018,8 @@
!
lastSpacePosition
+ "return the index of the last space character; 0 if there is none"
+
^ self lastIndexOfSeparator
!
@@ -1099,39 +1107,36 @@
| listOfLines currentLast currentStart resultString putativeLast putativeLine crPosition |
- aNumber isNumber not | (aNumber < 1) ifTrue: [self error: 'too narrow'].
+ (aNumber isNumber not or:[ aNumber < 1] ) ifTrue: [self error: 'too narrow'].
listOfLines _ OrderedCollection new.
currentLast _ 0.
[currentLast < self size] whileTrue:
- [currentStart _ currentLast + 1.
- putativeLast _ (currentStart + aNumber - 1) min: self size.
- putativeLine _ self copyFrom: currentStart to: putativeLast.
- (crPosition _ putativeLine indexOf: Character cr) > 0 ifTrue:
- [putativeLast _ currentStart + crPosition - 1.
- putativeLine _ self copyFrom: currentStart to: putativeLast].
- currentLast _ putativeLast == self size
- ifTrue:
- [putativeLast]
- ifFalse:
- [currentStart + putativeLine lastSpacePosition - 1].
- currentLast <= currentStart ifTrue:
- ["line has NO spaces; baleout!!"
- currentLast _ putativeLast].
- listOfLines add: (self copyFrom: currentStart to: currentLast) withBlanksTrimmed].
+ [currentStart _ currentLast + 1.
+ putativeLast _ (currentStart + aNumber - 1) min: self size.
+ putativeLine _ self copyFrom: currentStart to: putativeLast.
+ (crPosition _ putativeLine indexOf: Character cr) > 0 ifTrue:
+ [putativeLast _ currentStart + crPosition - 1.
+ putativeLine _ self copyFrom: currentStart to: putativeLast].
+ currentLast _ putativeLast == self size
+ ifTrue:
+ [putativeLast]
+ ifFalse:
+ [currentStart + putativeLine lastSpacePosition - 1].
+ currentLast <= currentStart ifTrue:
+ ["line has NO spaces; baleout!!"
+ currentLast _ putativeLast].
+ listOfLines add: (self copyFrom: currentStart to: currentLast) withBlanksTrimmed].
listOfLines size > 0 ifFalse: [^ ''].
resultString _ listOfLines first.
2 to: listOfLines size do:
- [:i | resultString _ resultString, Character cr asString, (listOfLines at: i)].
+ [:i | resultString _ resultString, Character cr asString, (listOfLines at: i)].
^ resultString
"
#(5 7 20) collect:
- [:i | 'Fred the bear went down to the brook to read his book in silence' withNoLineLongerThan: i]
- "
-
-
-
+ [:i | 'Fred the bear went down to the brook to read his book in silence' withNoLineLongerThan: i]
+ "
!
withSqueakLineEndings
@@ -1552,6 +1557,7 @@
^ true
! !
+
!CharacterArray methodsFor:'character searching'!
includesMatchCharacters
@@ -3713,6 +3719,11 @@
encodeFrom:oldEncoding into:newEncoding
^ CharacterEncoder encodeString:self from:oldEncoding into:newEncoding
+
+ "
+ 'äüö' encodeFrom:#iso8859 into:#utf8
+ ('äüö' encodeFrom:#iso8859 into:#utf8) encodeFrom:#utf8 into:#unicode
+ "
!
rot13
@@ -3933,7 +3944,7 @@
This is a q&d hack - not very efficient.
NOTICE: match-meta character interpretation is like in unix-matching (glob),
- NOT the ST-80 meaning.
+ NOT the ST-80 meaning.
NOTICE: this is GLOB, which is different from regex matching (see matchesRegex:)
NOTICE: the argument is the match pattern"
@@ -3948,40 +3959,41 @@
realMatchString := matchString.
(realMatchString endsWith:$*) ifFalse:[
- realMatchString := realMatchString , '*'.
- matchSize := matchSize + 1
+ realMatchString := realMatchString , '*'.
+ matchSize := matchSize + 1
].
mySize := self size.
firstChar := realMatchString at:1.
firstChar == self class matchEscapeCharacter ifTrue:[
- firstChar := realMatchString at:2.
+ firstChar := realMatchString at:2.
].
firstChar asString includesMatchCharacters ifTrue:[
- index to:mySize do:[:col |
- (realMatchString match:self from:col to:mySize ignoreCase:ignoreCase)
- ifTrue:[^ col]
- ].
- ^ exceptionBlock value.
+ index to:mySize do:[:col |
+ (realMatchString match:self from:col to:mySize ignoreCase:ignoreCase)
+ ifTrue:[^ col]
+ ].
+ ^ exceptionBlock value.
].
lcChar := firstChar asLowercase.
ucChar := firstChar asUppercase.
(ignoreCase and:[ lcChar ~= ucChar]) ifTrue:[
- firstSet := Array with:ucChar with:lcChar.
- startIndex := self indexOfAny:firstSet startingAt:index.
+ firstSet := Array with:ucChar with:lcChar.
+ startIndex := self indexOfAny:firstSet startingAt:index.
] ifFalse:[
- startIndex := self indexOf:firstChar startingAt:index.
+ startIndex := self indexOf:firstChar startingAt:index.
].
[startIndex == 0] whileFalse:[
- (realMatchString match:self from:startIndex to:mySize ignoreCase:ignoreCase)
- ifTrue:[^ startIndex].
- firstSet notNil ifTrue:[
- startIndex := self indexOfAny:firstSet startingAt:(startIndex + 1).
- ] ifFalse:[
- startIndex := self indexOf:firstChar startingAt:(startIndex + 1).
- ].
+ (realMatchString match:self from:startIndex to:mySize ignoreCase:ignoreCase)
+ ifTrue:[^ startIndex].
+
+ firstSet notNil ifTrue:[
+ startIndex := self indexOfAny:firstSet startingAt:(startIndex + 1).
+ ] ifFalse:[
+ startIndex := self indexOf:firstChar startingAt:(startIndex + 1).
+ ].
].
^ exceptionBlock value
@@ -4641,6 +4653,9 @@
!
hasChangeOfEmphasis
+ "return true, if the receiver contains non-empty emphasis information
+ i.e. any non-normal (=emphasized) characters"
+
^ false
"Created: 12.5.1996 / 12:31:39 / cg"
@@ -4978,7 +4993,9 @@
!
firstLine
- ^ self asCollectionOfSubCollectionsSeparatedBy:Character cr do:[:line | ^ line].
+ "return the first line of a multiline string"
+
+ ^ self asCollectionOfSubCollectionsSeparatedBy:(Character cr) do:[:line | ^ line].
"
'hello' firstLine
@@ -6079,15 +6096,15 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.475 2012/07/10 07:39:54 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.478 2012/10/29 11:55:18 cg Exp $'
!
version_CVS
- ^ '§Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.475 2012/07/10 07:39:54 stefan Exp §'
+ ^ '§Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.478 2012/10/29 11:55:18 cg Exp §'
!
version_SVN
- ^ '$Id: CharacterArray.st 10824 2012-07-18 16:55:48Z vranyj1 $'
+ ^ '$Id: CharacterArray.st 10858 2012-10-29 22:07:56Z vranyj1 $'
! !
CharacterArray initialize!