author | Claus Gittinger <cg@exept.de> |
Mon, 27 May 2019 16:53:37 +0200 | |
changeset 24192 | 18512bf68422 |
parent 23984 | ac00c411f7f6 |
permissions | -rw-r--r-- |
23984 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1 | 3 |
" |
4 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
235 | 5 |
All Rights Reserved |
1 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
10223
761e2a050b69
twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents:
8094
diff
changeset
|
14 |
"{ Package: 'stx:libbasic' }" |
8094
d05f69bd0097
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
5761
diff
changeset
|
15 |
|
17621 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
5761 | 18 |
CharacterArray variableWordSubclass:#TwoByteString |
992
f456f8f7d421
JIS decode now in CharacterArray
Claus Gittinger <cg@exept.de>
parents:
631
diff
changeset
|
19 |
instanceVariableNames:'' |
f456f8f7d421
JIS decode now in CharacterArray
Claus Gittinger <cg@exept.de>
parents:
631
diff
changeset
|
20 |
classVariableNames:'' |
f456f8f7d421
JIS decode now in CharacterArray
Claus Gittinger <cg@exept.de>
parents:
631
diff
changeset
|
21 |
poolDictionaries:'' |
f456f8f7d421
JIS decode now in CharacterArray
Claus Gittinger <cg@exept.de>
parents:
631
diff
changeset
|
22 |
category:'Collections-Text' |
1 | 23 |
! |
24 |
||
89 | 25 |
!TwoByteString class methodsFor:'documentation'! |
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
235 | 30 |
All Rights Reserved |
1 | 31 |
|
89 | 32 |
This software is furnished under a license and may be used |
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
41 |
documentation |
|
42 |
" |
|
43 |
TwoByteStrings are like strings, but storing 16bits per character. |
|
44 |
The integration of them into the system is not completed .... |
|
1290 | 45 |
|
46 |
[author:] |
|
47 |
Claus Gittinger |
|
1309 | 48 |
|
49 |
[see also:] |
|
1382 | 50 |
Text JISEncodedString |
1309 | 51 |
StringCollection |
89 | 52 |
" |
1214 | 53 |
! ! |
54 |
||
55 |
!TwoByteString class methodsFor:'initialization'! |
|
996 | 56 |
|
57 |
initialize |
|
1253 | 58 |
"initialize the class - private" |
59 |
||
996 | 60 |
self flags:(Behavior flagWords) |
61 |
||
62 |
" |
|
63 |
TwoByteString initialize |
|
64 |
" |
|
1214 | 65 |
|
1253 | 66 |
"Modified: 22.4.1996 / 16:14:14 / cg" |
89 | 67 |
! ! |
1 | 68 |
|
69 |
!TwoByteString class methodsFor:'instance creation'! |
|
70 |
||
71 |
basicNew:anInteger |
|
22375 | 72 |
"return a new empty string with anInteger number of characters" |
1 | 73 |
|
1024 | 74 |
^ (super basicNew:anInteger) atAllPut:(Character space) |
75 |
||
22375 | 76 |
"Modified: / 26-02-1996 / 14:38:47 / cg" |
77 |
"Modified (comment): / 22-11-2017 / 21:32:49 / cg" |
|
17621 | 78 |
! |
79 |
||
80 |
uninitializedNew:anInteger |
|
81 |
"return a new empty string with anInteger characters" |
|
82 |
||
83 |
^ super basicNew:anInteger |
|
84 |
||
85 |
" |
|
86 |
self uninitializedNew:10 |
|
87 |
" |
|
1 | 88 |
! ! |
89 |
||
90 |
!TwoByteString methodsFor:'accessing'! |
|
91 |
||
92 |
basicAt:index |
|
93 |
"return the character at position index, an Integer |
|
73 | 94 |
- reimplemented here since we return 16-bit characters" |
1 | 95 |
|
1024 | 96 |
|val| |
63 | 97 |
|
1024 | 98 |
val := super basicAt:index. |
63 | 99 |
^ Character value:val |
1024 | 100 |
|
101 |
"Modified: 26.2.1996 / 17:02:16 / cg" |
|
1 | 102 |
! |
103 |
||
104 |
basicAt:index put:aCharacter |
|
1230 | 105 |
"store the argument, aCharacter at position index, an Integer. |
106 |
Returns aCharacter (sigh). |
|
73 | 107 |
- reimplemented here since we store 16-bit characters" |
1 | 108 |
|
8094
d05f69bd0097
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
5761
diff
changeset
|
109 |
super basicAt:index put:aCharacter codePoint. |
63 | 110 |
^ aCharacter |
608 | 111 |
|
1230 | 112 |
"Modified: 19.4.1996 / 11:16:22 / cg" |
14123 | 113 |
! |
114 |
||
115 |
unsignedShortAt:index |
|
116 |
"return the short at position index, an Integer" |
|
117 |
||
118 |
^ super basicAt:index. |
|
1014 | 119 |
! ! |
120 |
||
16750 | 121 |
!TwoByteString methodsFor:'filling and replacing'! |
122 |
||
23974 | 123 |
from:start to:stop put:aCharacter |
124 |
"fill part of the receiver with aCharacter. |
|
125 |
- reimplemented here for speed" |
|
126 |
||
127 |
%{ /* NOCONTEXT */ |
|
128 |
||
129 |
REGISTER unsigned short *dstp; |
|
130 |
REGISTER int count, charValue; |
|
131 |
||
132 |
// fprintf(stderr, "fill16...\n"); |
|
133 |
if (__isCharacter(aCharacter) |
|
134 |
&& __bothSmallInteger(start, stop)) { |
|
23984 | 135 |
int len, index1, index2; |
136 |
OBJ cls; |
|
137 |
||
23974 | 138 |
len = __twoByteStringSize(self); |
139 |
index1 = __intVal(start); |
|
140 |
index2 = __intVal(stop); |
|
141 |
||
142 |
dstp = __twoByteStringVal(self) + index1 - 1; |
|
23984 | 143 |
if (((cls = __qClass(self)) == Unicode16String) |
144 |
|| (__OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)) == 0)) { |
|
23974 | 145 |
|
23984 | 146 |
charValue = __intVal(__characterVal(aCharacter)); |
147 |
if (((unsigned)charValue <= 0xFFFF) |
|
148 |
&& (index1 <= index2) |
|
149 |
&& (index1 > 0)) { |
|
150 |
if (index2 <= len) { |
|
151 |
count = index2 - index1 + 1; |
|
23974 | 152 |
|
153 |
#if (__POINTER_SIZE__ == 8) |
|
23984 | 154 |
{ |
155 |
INT v4; |
|
23974 | 156 |
|
23984 | 157 |
v4 = (charValue << 16) | charValue; |
158 |
v4 = (v4 << 32) | v4; |
|
23974 | 159 |
|
23984 | 160 |
/* fill unaligned part */ |
161 |
while ((count > 0) && (((unsigned INT)dstp & 7) != 0)) { |
|
162 |
*dstp++ = charValue; |
|
163 |
count--; |
|
164 |
} |
|
23974 | 165 |
|
23984 | 166 |
/* fill aligned part */ |
167 |
while (count >= 4) { |
|
168 |
((unsigned INT *)dstp)[0] = v4; |
|
169 |
dstp += 4; |
|
170 |
count -= 4; |
|
171 |
} |
|
172 |
||
173 |
/* fill rest */ |
|
174 |
while (count > 0) { |
|
175 |
*dstp++ = charValue; |
|
176 |
count--; |
|
177 |
} |
|
178 |
RETURN (self); |
|
23974 | 179 |
} |
23984 | 180 |
#endif /* 64bit */ |
23974 | 181 |
|
23984 | 182 |
while (count >= 8) { |
183 |
dstp[0] = dstp[1] = dstp[2] = dstp[3] = |
|
184 |
dstp[4] = dstp[5] = dstp[6] = dstp[7] = charValue; |
|
185 |
dstp += 8; |
|
186 |
count -= 8; |
|
187 |
} |
|
188 |
while (count--) { |
|
23974 | 189 |
*dstp++ = charValue; |
190 |
} |
|
191 |
RETURN (self); |
|
192 |
} |
|
193 |
} |
|
194 |
} |
|
195 |
} |
|
196 |
%}. |
|
197 |
" |
|
198 |
fall back in case of non-integer index or out-of-bound index/value; |
|
199 |
will eventually lead to an out-of-bound signal raise |
|
200 |
" |
|
201 |
^ super from:start to:stop put:aCharacter |
|
202 |
||
203 |
" |
|
204 |
(Unicode16String new:10) from:1 to:10 put:$a |
|
205 |
(Unicode16String new:20) from:10 to:20 put:$b |
|
206 |
(Unicode16String new:20) from:1 to:10 put:$c |
|
207 |
(Unicode16String new:20) from:1 to:10 put:$c |
|
208 |
(Unicode16String new:100) from:2 to:99 put:$c |
|
209 |
||
210 |
(Unicode16String new:10) from:0 to:9 put:$a |
|
211 |
(Unicode16String new:10) from:1 to:11 put:$a |
|
212 |
" |
|
213 |
||
214 |
"Created: / 26-03-2019 / 11:20:14 / Claus Gittinger" |
|
23984 | 215 |
"Modified: / 27-03-2019 / 14:05:10 / Claus Gittinger" |
23974 | 216 |
! |
217 |
||
16750 | 218 |
replaceFrom:start to:stop with:aString startingAt:repStart |
219 |
"replace the characters starting at index start, anInteger and ending |
|
220 |
at stop, anInteger with characters from aString starting at repStart. |
|
221 |
Return the receiver. |
|
222 |
||
223 |
- reimplemented here for speed" |
|
224 |
||
225 |
%{ /* NOCONTEXT */ |
|
226 |
||
227 |
#ifndef NO_PRIM_STRING |
|
228 |
if (__bothSmallInteger(start, stop)) { |
|
18576 | 229 |
int len; |
230 |
int index1 = __intVal(start); |
|
231 |
int index2 = __intVal(stop); |
|
232 |
int count = index2 - index1 + 1; |
|
16750 | 233 |
|
234 |
if (count <= 0) { |
|
235 |
RETURN (self); |
|
236 |
} |
|
237 |
len = __twoByteStringSize(self); |
|
238 |
if ((index2 <= len) && (index1 > 0)) { |
|
18576 | 239 |
int repIndex = __intVal(repStart); |
23984 | 240 |
OBJ cls; |
241 |
||
242 |
if (((cls = __qClass(self)) == Unicode16String) |
|
243 |
|| (__OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)) == 0)) { |
|
244 |
if (__isStringLike(aString)) { |
|
245 |
int repLen = __stringSize(aString); |
|
246 |
if ((repIndex > 0) && ((repIndex + count - 1) <= repLen)) { |
|
247 |
REGISTER unsigned char *srcp = __stringVal(aString) + repIndex - 1; |
|
248 |
REGISTER unsigned short *dstp = __twoByteStringVal(self) + index1 - 1; |
|
16750 | 249 |
|
250 |
while (count-- > 0) { |
|
251 |
*dstp++ = *srcp++; |
|
252 |
} |
|
23984 | 253 |
RETURN (self); |
16750 | 254 |
} |
23984 | 255 |
} else if (__isTwoByteString(aString) || __isUnicode16String(aString)) { |
256 |
int repLen = __twoByteStringSize(aString); |
|
257 |
if ((repIndex > 0) && ((repIndex + count - 1) <= repLen)) { |
|
258 |
REGISTER unsigned short *srcp = __twoByteStringVal(aString) + repIndex - 1; |
|
259 |
REGISTER unsigned short *dstp = __twoByteStringVal(self) + index1 - 1; |
|
260 |
||
261 |
if (aString == self) { |
|
262 |
/* take care of overlapping copy */ |
|
263 |
memmove(dstp, srcp, count*sizeof(short)); |
|
264 |
RETURN (self); |
|
265 |
} |
|
266 |
if (count > 5) { |
|
267 |
memcpy(dstp, srcp, count*sizeof(short)); |
|
268 |
} else { |
|
269 |
while (count-- > 0) { |
|
270 |
*dstp++ = *srcp++; |
|
271 |
} |
|
272 |
} |
|
273 |
RETURN (self); |
|
274 |
} |
|
16750 | 275 |
} |
276 |
} |
|
277 |
} |
|
278 |
} |
|
279 |
#endif |
|
280 |
%}. |
|
281 |
"/ arrive here if any index arg is out o range, or the source is neither a string, |
|
282 |
"/ nor a two-byte string. |
|
283 |
^ super replaceFrom:start to:stop with:aString startingAt:repStart |
|
284 |
||
285 |
" |
|
286 |
'hello world' asUnicode16String replaceFrom:1 to:5 with:'123456' startingAt:2 |
|
287 |
'hello world' asUnicode16String replaceFrom:1 to:5 with:'123456' asUnicode16String startingAt:2 |
|
288 |
'hello world' asUnicode16String replaceFrom:1 to:0 with:'123456' startingAt:2 |
|
289 |
'hello' asUnicode16String replaceFrom:1 to:6 with:'123456' startingAt:2 |
|
290 |
'hello world' asUnicode16String replaceFrom:1 to:1 with:'123456' startingAt:2 |
|
291 |
" |
|
23984 | 292 |
|
293 |
"Modified: / 27-03-2019 / 14:03:27 / Claus Gittinger" |
|
16750 | 294 |
! ! |
295 |
||
608 | 296 |
!TwoByteString methodsFor:'queries'! |
297 |
||
1017 | 298 |
bitsPerCharacter |
1239 | 299 |
"return the number of bits each character has. |
300 |
Here, 16 is returned (storing double byte characters)." |
|
301 |
||
1017 | 302 |
^ 16 |
1239 | 303 |
|
304 |
"Modified: 20.4.1996 / 23:08:38 / cg" |
|
14557 | 305 |
! |
306 |
||
19758 | 307 |
bytesPerCharacter |
308 |
"return the number of bytes each character has. |
|
309 |
Here, 2 is returned (storing double byte characters)." |
|
310 |
||
311 |
^ 2 |
|
312 |
! |
|
313 |
||
18593 | 314 |
characterSize |
315 |
"answer the size in bits of my largest character (actually only 7, 8 or 16)" |
|
316 |
||
317 |
%{ /* NOCONTEXT */ |
|
318 |
||
319 |
REGISTER unsigned short *sp = __twoByteStringVal(self); |
|
320 |
REGISTER unsigned short *last = sp + __twoByteStringSize(self); |
|
321 |
OBJ cls = __qClass(self); |
|
322 |
int has8BitChars = 0; |
|
323 |
||
23984 | 324 |
if (cls != Unicode16String) { |
18593 | 325 |
sp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)) / 2; |
326 |
} |
|
18586 | 327 |
|
18593 | 328 |
#if __POINTER_SIZE__ == 8 |
329 |
if (sizeof(unsigned INT) == 8) { |
|
330 |
if (!has8BitChars) { |
|
331 |
for ( ; (sp+4) <= last; sp += 4) { |
|
332 |
if (*(unsigned INT *)sp & 0xFF80FF80FF80FF80) { |
|
333 |
/* there are at least 8-bit chars - check for more */ |
|
334 |
has8BitChars = 1; |
|
335 |
break; |
|
336 |
} |
|
337 |
} |
|
338 |
} |
|
339 |
for ( ; (sp+4) <= last; sp += 4) { |
|
340 |
if (*(unsigned INT *)sp & 0xFF00FF00FF00FF00) { |
|
341 |
RETURN(__mkSmallInteger(16)); |
|
342 |
} |
|
343 |
} |
|
344 |
} |
|
345 |
#endif |
|
346 |
if (sizeof(unsigned int) == 4) { |
|
347 |
if (!has8BitChars) { |
|
348 |
for ( ; (sp+2) <= last; sp += 2) { |
|
349 |
if (*(unsigned int *)sp & 0xFF80FF80) { |
|
350 |
/* there are at least 8-bit chars - check for more */ |
|
351 |
has8BitChars = 1; |
|
352 |
break; |
|
353 |
} |
|
354 |
} |
|
355 |
} |
|
356 |
for ( ; (sp+2) <= last; sp += 2) { |
|
357 |
if (*(unsigned int *)sp & 0xFF00FF00) { |
|
358 |
RETURN(__mkSmallInteger(16)); |
|
359 |
} |
|
360 |
} |
|
361 |
} |
|
362 |
if (!has8BitChars) { |
|
363 |
for ( ; sp < last; sp++) { |
|
364 |
if (*sp & 0xFF80) { |
|
365 |
/* there are at least 8-bit chars - check for more */ |
|
366 |
has8BitChars = 1; |
|
367 |
break; |
|
368 |
} |
|
369 |
} |
|
370 |
} |
|
371 |
for ( ; sp < last; sp++) { |
|
372 |
if (*sp & 0xFF00) { |
|
373 |
RETURN(__mkSmallInteger(16)); |
|
374 |
} |
|
375 |
} |
|
376 |
RETURN (__mkSmallInteger(has8BitChars ? 8 : 7)); |
|
377 |
%}. |
|
378 |
||
379 |
" |
|
380 |
'hello world' asUnicode16String characterSize |
|
23984 | 381 |
'hello worldüäö' asUnicode16String characterSize |
18593 | 382 |
'a' asUnicode16String characterSize |
23984 | 383 |
'ü' asUnicode16String characterSize |
18593 | 384 |
'aa' asUnicode16String characterSize |
23984 | 385 |
'aü' asUnicode16String characterSize |
18593 | 386 |
'aaa' asUnicode16String characterSize |
23984 | 387 |
'aaü' asUnicode16String characterSize |
388 |
'aaaü' asUnicode16String characterSize |
|
18593 | 389 |
'aaaa' asUnicode16String characterSize |
23984 | 390 |
'aaaaü' asUnicode16String characterSize |
18593 | 391 |
" |
23984 | 392 |
|
393 |
"Modified: / 27-03-2019 / 14:06:56 / Claus Gittinger" |
|
18586 | 394 |
! |
395 |
||
18593 | 396 |
containsNon7BitAscii |
17621 | 397 |
"return true, if the underlying string contains 8BitCharacters (or widers) |
398 |
(i.e. if it is non-ascii)" |
|
399 |
||
400 |
%{ /* NOCONTEXT */ |
|
401 |
||
18593 | 402 |
REGISTER unsigned short *sp = __twoByteStringVal(self); |
403 |
REGISTER unsigned short *last = sp + __twoByteStringSize(self); |
|
404 |
OBJ cls = __qClass(self); |
|
17621 | 405 |
|
23984 | 406 |
if (cls != Unicode16String) { |
17621 | 407 |
sp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)) / 2; |
408 |
} |
|
409 |
#if __POINTER_SIZE__ == 8 |
|
18593 | 410 |
if (sizeof(unsigned INT) == 8) { |
411 |
for ( ; (sp+4) <= last; sp += 4) { |
|
412 |
if (*(unsigned INT *)sp & 0xFF80FF80FF80FF80) { |
|
17621 | 413 |
RETURN ( true ); |
414 |
} |
|
415 |
} |
|
416 |
} |
|
417 |
#endif |
|
18593 | 418 |
if (sizeof(unsigned int) == 4) { |
419 |
for ( ; (sp+2) <= last; sp += 2) { |
|
17621 | 420 |
if (*(unsigned int *)sp & 0xFF80FF80) { |
421 |
RETURN ( true ); |
|
422 |
} |
|
423 |
} |
|
424 |
} |
|
18593 | 425 |
for ( ; sp < last; sp++) { |
17621 | 426 |
if (*sp & 0xFF80) { |
427 |
RETURN ( true ); |
|
428 |
} |
|
429 |
} |
|
430 |
RETURN (false); |
|
431 |
%}. |
|
432 |
||
433 |
" |
|
18593 | 434 |
'hello world' asUnicode16String containsNon7BitAscii |
23984 | 435 |
'hello worldüäö' asUnicode16String containsNon7BitAscii |
436 |
'ü' asUnicode16String containsNon7BitAscii |
|
437 |
'aü' asUnicode16String containsNon7BitAscii |
|
438 |
'aaü' asUnicode16String containsNon7BitAscii |
|
439 |
'aaaü' asUnicode16String containsNon7BitAscii |
|
440 |
'aaaaü' asUnicode16String containsNon7BitAscii |
|
18593 | 441 |
'aaaaa' asUnicode16String containsNon7BitAscii |
17621 | 442 |
" |
23984 | 443 |
|
444 |
"Modified: / 27-03-2019 / 14:07:10 / Claus Gittinger" |
|
17621 | 445 |
! |
446 |
||
14557 | 447 |
isWideString |
19581 | 448 |
"true if I require more than one byte per character" |
449 |
||
14557 | 450 |
^ true |
23984 | 451 |
! |
452 |
||
453 |
occurrencesOf:aCharacter |
|
454 |
"count the occurrences of the argument, aCharacter in myself |
|
455 |
- reimplemented here for speed" |
|
456 |
||
457 |
%{ /* NOCONTEXT */ |
|
458 |
||
459 |
REGISTER unsigned charValue; |
|
460 |
REGISTER INT count, limit; |
|
461 |
||
462 |
if (__isCharacter(aCharacter)) { |
|
463 |
limit = __unicode16StringSize(self); |
|
464 |
count = 0; |
|
465 |
charValue = __intVal(__characterVal(aCharacter)); |
|
466 |
if (charValue <= 0xFFFF) { |
|
467 |
OBJ cls; |
|
468 |
REGISTER unsigned short* cp; |
|
469 |
||
470 |
cp = __unicode16StringVal(self); |
|
471 |
if (((cls = __qClass(self)) == Unicode16String) |
|
472 |
|| (__OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)) == 0)) { |
|
473 |
/* loop unrolled and software-pipelined |
|
474 |
* (gives 30-40% speedup on Intel-DUO using borland bcc55) |
|
475 |
*/ |
|
476 |
while (limit >= 4) { |
|
477 |
register unsigned short c1, c2; |
|
478 |
||
479 |
c1 = cp[0]; |
|
480 |
limit -= 4; |
|
481 |
c2 = cp[1]; |
|
482 |
if (c1 == charValue) count++; |
|
483 |
c1 = cp[2]; |
|
484 |
if (c2 == charValue) count++; |
|
485 |
c2 = cp[3]; |
|
486 |
if (c1 == charValue) count++; |
|
487 |
cp += 4; |
|
488 |
if (c2 == charValue) count++; |
|
489 |
} |
|
490 |
while (limit > 0) { |
|
491 |
register unsigned short c; |
|
492 |
||
493 |
c = cp[0]; |
|
494 |
limit--; |
|
495 |
if (c == charValue) count++; |
|
496 |
cp++; |
|
497 |
} |
|
498 |
} |
|
499 |
RETURN ( __mkSmallInteger(count) ); |
|
500 |
} |
|
501 |
} |
|
502 |
%}. |
|
503 |
^ super occurrencesOf:aCharacter |
|
504 |
||
505 |
" |
|
506 |
'hello world' occurrencesOf:$a |
|
507 |
'hello world' occurrencesOf:$w |
|
508 |
'hello world' occurrencesOf:$l |
|
509 |
'hello world' occurrencesOf:$x |
|
510 |
'hello world' occurrencesOf:1 |
|
511 |
Time millisecondsToRun:[ |
|
512 |
|s| |
|
513 |
||
514 |
s := 'abcdefghijklmn' asUnicode16String. |
|
515 |
1000000 timesRepeat:[ s occurrencesOf:$x ] |
|
516 |
]. 60 60 60 70 (untuned: 670 710 740) |
|
517 |
" |
|
518 |
||
519 |
"Created: / 27-03-2019 / 13:58:55 / Claus Gittinger" |
|
608 | 520 |
! ! |
521 |
||
22226 | 522 |
!TwoByteString methodsFor:'testing'! |
523 |
||
22228 | 524 |
isSingleByteCollection |
525 |
"return true, if the receiver has access methods for bytes; |
|
526 |
i.e. #at: and #at:put: accesses a byte and are equivalent to #byteAt: and byteAt:put: |
|
527 |
and #replaceFrom:to: is equivalent to #replaceBytesFrom:to:. |
|
528 |
false is returned here since at: returns 2-byte characters and not bytes |
|
529 |
- the method is redefined from UninterpretedBytes." |
|
530 |
||
22226 | 531 |
^ false |
532 |
||
533 |
"Created: / 30-08-2017 / 23:30:36 / cg" |
|
534 |
! ! |
|
535 |
||
631 | 536 |
!TwoByteString class methodsFor:'documentation'! |
537 |
||
538 |
version |
|
18576 | 539 |
^ '$Header$' |
23984 | 540 |
! |
541 |
||
542 |
version_CVS |
|
543 |
^ '$Header$' |
|
631 | 544 |
! ! |
8094
d05f69bd0097
Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents:
5761
diff
changeset
|
545 |
|
16750 | 546 |
|
996 | 547 |
TwoByteString initialize! |