2836 ^ String fromString:self |
2834 ^ String fromString:self |
2837 |
2835 |
2838 " |
2836 " |
2839 #[60 61 62 63] asSingleByteString |
2837 #[60 61 62 63] asSingleByteString |
2840 #[60 61 62 63] asExternalBytes asSingleByteString |
2838 #[60 61 62 63] asExternalBytes asSingleByteString |
|
2839 #[67 68 69 70] asIntegerArray asSingleByteString |
2841 (Unicode16String with:(Character value:16rFF)) asSingleByteString |
2840 (Unicode16String with:(Character value:16rFF)) asSingleByteString |
2842 (Unicode16String with:(Character value:16rFFFF)) asSingleByteString |
2841 (Unicode16String with:(Character value:16rFFFF)) asSingleByteString |
|
2842 " |
|
2843 ! |
|
2844 |
|
2845 asSingleByteStringIfPossible |
|
2846 "if possible, return the receiver converted to a 'normal' string. |
|
2847 It is only possible, if there are no characters with codePoints above 255 in the receiver. |
|
2848 If not possible, the (wideString) receiver is returned." |
|
2849 |
|
2850 self containsNon8BitElements ifTrue:[^ self asString]. |
|
2851 ^ self asSingleByteString. |
|
2852 |
|
2853 " |
|
2854 #[67 68 69 70] asSingleByteStringIfPossible |
|
2855 #[67 68 69 70] asIntegerArray asSingleByteStringIfPossible |
|
2856 'hello' asUnicodeString asSingleByteStringIfPossible |
2843 " |
2857 " |
2844 ! |
2858 ! |
2845 |
2859 |
2846 asString |
2860 asString |
2847 "speed up string conversions" |
2861 "speed up string conversions" |
3424 " |
3438 " |
3425 ! ! |
3439 ! ! |
3426 |
3440 |
3427 !UninterpretedBytes methodsFor:'private'! |
3441 !UninterpretedBytes methodsFor:'private'! |
3428 |
3442 |
3429 slowReplaceBytesFrom:start to:stop with:sourceBytes startingAt:sourceIndex |
3443 slowReplaceBytesFrom:startArg to:stopArg with:sourceBytes startingAt:sourceIndex |
3430 "fallback if primitive code fails" |
3444 "fallback if primitive code fails" |
3431 |
3445 |
3432 |srcIdx| |
3446 |srcIdx "{ Class:SmallInteger }" |
3433 |
3447 start "{ Class:SmallInteger }" |
|
3448 stop "{ Class:SmallInteger }"| |
|
3449 |
|
3450 start := startArg. |
|
3451 stop := stopArg. |
3434 srcIdx := sourceIndex. |
3452 srcIdx := sourceIndex. |
|
3453 |
3435 start to:stop do:[:dstIdx | |
3454 start to:stop do:[:dstIdx | |
3436 self at:dstIdx put:(sourceBytes at:srcIdx). |
3455 self at:dstIdx put:(sourceBytes at:srcIdx). |
3437 srcIdx := srcIdx + 1 |
3456 srcIdx := srcIdx + 1 |
3438 ]. |
3457 ]. |
3439 ! ! |
3458 ! ! |
3440 |
3459 |
3441 !UninterpretedBytes methodsFor:'queries'! |
3460 !UninterpretedBytes methodsFor:'queries'! |
3442 |
3461 |
3443 containsNon7BitAscii |
3462 containsNon7BitAscii |
3444 "return true, if the underlying string contains 8BitCharacters (or widers) |
3463 "return true, if the underlying collection contains elements longer than 7 bits |
3445 (i.e. if it is non-ascii)" |
3464 (i.e. if it is non-ascii)" |
3446 |
3465 |
3447 |sz "{ Class:SmallInteger }"| |
3466 |sz "{ Class:SmallInteger }"| |
3448 |
3467 |
3449 sz := self size. |
3468 sz := self size. |
3450 1 to:sz do:[:idx| |
3469 1 to:sz do:[:idx| |
3451 (self at:idx) > 16r7F ifTrue:[ |
3470 (self at:idx) > 16r7F ifTrue:[ |
3452 ^ true. |
3471 ^ true. |
3453 ]. |
3472 ]. |
|
3473 ]. |
|
3474 ^ false. |
|
3475 ! |
|
3476 |
|
3477 containsNon8BitElements |
|
3478 "return true, if the underlying structure contains elements larger than a single byte" |
|
3479 |
|
3480 |sz "{ Class:SmallInteger }"| |
|
3481 |
|
3482 sz := self size. |
|
3483 1 to:sz do:[:idx| |
|
3484 (self at:idx) > 16rFF ifTrue:[ |
|
3485 ^ true. |
|
3486 ]. |
3454 ]. |
3487 ]. |
3455 ^ false. |
3488 ^ false. |
3456 ! |
3489 ! |
3457 |
3490 |
3458 defaultElement |
3491 defaultElement |