137 " |
137 " |
138 Strings are ByteArrays storing Characters. |
138 Strings are ByteArrays storing Characters. |
139 |
139 |
140 Strings are kind of kludgy: to allow for easy handling by C functions, |
140 Strings are kind of kludgy: to allow for easy handling by C functions, |
141 there is always one 0-byte added at the end, which is not counted |
141 there is always one 0-byte added at the end, which is not counted |
142 in the strings size, and is not accessible from the smalltalk level. |
142 in the string's size, and is not accessible from the Smalltalk level. |
143 This guarantees, that a smalltalk string can always be passed to a |
143 This guarantees, that a Smalltalk string can always be passed to a |
144 C- or a system api function without danger (of course, this does not |
144 C- or a system api function without danger |
145 prevent a nonsense contents ...) |
145 (of course, this does not prevent a nonsense contents...) |
146 |
146 |
147 You cannot add any instvars to String, since the run time system & compiler |
147 You cannot add any instvars to String, since the run time system & compiler |
148 creates literal strings and knows that strings have no named instvars. |
148 creates literal strings and knows that strings have no named instvars. |
149 If you really need strings with instVars, you have to create a subclass |
149 If you really need strings with instVars, you have to create a subclass |
150 of String (the access functions defined here can handle this). |
150 of String (the access functions defined here can handle this). |
151 A little warning though: not all smalltalk systems allow subclassing String, |
151 A little warning though: not all Smalltalk systems allow subclassing String, |
152 so your program may become unportable if you do so. |
152 so your program may become unportable if you do so. |
153 |
153 |
154 Strings have an implicit (assumed) encoding of ISO-8859-1. |
154 Strings have an implicit (assumed) encoding of ISO-8859-1. |
155 For strings with other encodings, either keep the encoding separately, |
155 For strings with other encodings, either keep the encoding separately, |
156 or use instances of encodedString. |
156 or use instances of encodedString. |
159 the implementations of some String methods use C functions and may |
159 the implementations of some String methods use C functions and may |
160 therefore yield unexpected results (e.g. compareWith:collating:) when |
160 therefore yield unexpected results (e.g. compareWith:collating:) when |
161 processing a String containing the 0-byte. |
161 processing a String containing the 0-byte. |
162 |
162 |
163 [author:] |
163 [author:] |
164 Claus Gittinger |
164 Claus Gittinger |
165 |
165 |
166 [see also:] |
166 [see also:] |
167 Text StringCollection TwoByteString JISEncodedString |
167 Text StringCollection TwoByteString JISEncodedString |
168 Symbol |
168 Symbol |
169 " |
169 " |
170 ! ! |
170 ! ! |
171 |
171 |
172 !String class methodsFor:'instance creation'! |
172 !String class methodsFor:'instance creation'! |
173 |
173 |
5101 |
5107 |
5102 "Created: / 01-05-2017 / 12:50:18 / cg" |
5108 "Created: / 01-05-2017 / 12:50:18 / cg" |
5103 "Modified (comment): / 01-05-2017 / 14:05:41 / cg" |
5109 "Modified (comment): / 01-05-2017 / 14:05:41 / cg" |
5104 ! ! |
5110 ! ! |
5105 |
5111 |
|
5112 |
5106 !String methodsFor:'substring searching'! |
5113 !String methodsFor:'substring searching'! |
5107 |
5114 |
5108 caseInsensitiveIndexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue |
5115 caseInsensitiveIndexOfSubCollection:aSubString startingAt:startIndex ifAbsent:exceptionValue |
5109 "naive search fallback (non-BM). |
5116 "naive search fallback (non-BM). |
5110 Private method to speed up caseInSensitive searches" |
5117 Private method to speed up caseInSensitive searches" |