TwoByteString.st
author Stefan Vogel <sv@exept.de>
Sat, 18 Jul 2015 01:22:18 +0200
changeset 18593 e69a425e3823
parent 18586 b8798de459f4
child 18606 5d9eaf7bf761
child 18608 7d521f25267c
permissions -rw-r--r--
class: TwoByteString added: #characterSize #containsNon7BitAscii removed: #bitsPerCharacterInString #contains8BitCharacters changed: #utf8Encoded (send #containsNon7BitAscii instead of #contains8BitCharacters) #utf8EncodedOn: (send #containsNon7BitAscii instead of #contains8BitCharacters)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18586
b8798de459f4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18576
diff changeset
     1
"{ Encoding: utf8 }"
b8798de459f4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18576
diff changeset
     2
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     3
"
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
 COPYRIGHT (c) 1993 by Claus Gittinger
235
d8e62525bfdf *** empty log message ***
claus
parents: 97
diff changeset
     5
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    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
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    16
"{ NameSpace: Smalltalk }"
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    17
5761
9693ef8bbadd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4219
diff changeset
    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
a27a279701f8 Initial revision
claus
parents:
diff changeset
    23
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    24
89
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    25
!TwoByteString class methodsFor:'documentation'!
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    26
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    27
copyright
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    28
"
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    29
 COPYRIGHT (c) 1993 by Claus Gittinger
235
d8e62525bfdf *** empty log message ***
claus
parents: 97
diff changeset
    30
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    31
89
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    32
 This software is furnished under a license and may be used
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    33
 only in accordance with the terms of that license and with the
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    35
 be provided or otherwise made available to, or used by, any
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    36
 other person.  No title to or ownership of the software is
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    37
 hereby transferred.
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    38
"
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    39
!
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    40
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    41
documentation
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    42
"
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    43
    TwoByteStrings are like strings, but storing 16bits per character.
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    44
    The integration of them into the system is not completed ....
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
    45
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
    46
    [author:]
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1253
diff changeset
    47
        Claus Gittinger
1309
24c98ca4a56d commentary
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    48
24c98ca4a56d commentary
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    49
    [see also:]
1382
93c125a594c3 xref in doku
Claus Gittinger <cg@exept.de>
parents: 1309
diff changeset
    50
        Text JISEncodedString
1309
24c98ca4a56d commentary
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    51
        StringCollection
89
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    52
"
1214
Claus Gittinger <cg@exept.de>
parents: 1024
diff changeset
    53
! !
Claus Gittinger <cg@exept.de>
parents: 1024
diff changeset
    54
Claus Gittinger <cg@exept.de>
parents: 1024
diff changeset
    55
!TwoByteString class methodsFor:'initialization'!
996
560a05298da9 I really store shorts ...
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
    56
560a05298da9 I really store shorts ...
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
    57
initialize
1253
7265cbaa8ec9 commentary
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
    58
    "initialize the class - private"
7265cbaa8ec9 commentary
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
    59
996
560a05298da9 I really store shorts ...
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
    60
    self flags:(Behavior flagWords)
560a05298da9 I really store shorts ...
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
    61
560a05298da9 I really store shorts ...
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
    62
    "
560a05298da9 I really store shorts ...
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
    63
     TwoByteString initialize
560a05298da9 I really store shorts ...
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
    64
    "
1214
Claus Gittinger <cg@exept.de>
parents: 1024
diff changeset
    65
1253
7265cbaa8ec9 commentary
Claus Gittinger <cg@exept.de>
parents: 1239
diff changeset
    66
    "Modified: 22.4.1996 / 16:14:14 / cg"
89
7be0b86ef80f *** empty log message ***
claus
parents: 73
diff changeset
    67
! !
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    68
a27a279701f8 Initial revision
claus
parents:
diff changeset
    69
!TwoByteString class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    70
a27a279701f8 Initial revision
claus
parents:
diff changeset
    71
basicNew:anInteger
a27a279701f8 Initial revision
claus
parents:
diff changeset
    72
    "return a new empty string with anInteger characters"
a27a279701f8 Initial revision
claus
parents:
diff changeset
    73
1024
9a14acfb50ee 16bit coding
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
    74
    ^ (super basicNew:anInteger) atAllPut:(Character space)
9a14acfb50ee 16bit coding
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
    75
9a14acfb50ee 16bit coding
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
    76
    "Modified: 26.2.1996 / 14:38:47 / cg"
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    77
!
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    78
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    79
uninitializedNew:anInteger
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    80
    "return a new empty string with anInteger characters"
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    81
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    82
    ^ super basicNew:anInteger
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    83
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    84
    "
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    85
        self uninitializedNew:10
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
    86
    "
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    87
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
    88
a27a279701f8 Initial revision
claus
parents:
diff changeset
    89
!TwoByteString methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    90
a27a279701f8 Initial revision
claus
parents:
diff changeset
    91
basicAt:index
a27a279701f8 Initial revision
claus
parents:
diff changeset
    92
    "return the character at position index, an Integer
73
a6640cc96199 *** empty log message ***
claus
parents: 63
diff changeset
    93
     - reimplemented here since we return 16-bit characters"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    94
1024
9a14acfb50ee 16bit coding
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
    95
    |val|
63
1f0cdefb013f *** empty log message ***
claus
parents: 33
diff changeset
    96
1024
9a14acfb50ee 16bit coding
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
    97
    val := super basicAt:index.
63
1f0cdefb013f *** empty log message ***
claus
parents: 33
diff changeset
    98
    ^ Character value:val
1024
9a14acfb50ee 16bit coding
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
    99
9a14acfb50ee 16bit coding
Claus Gittinger <cg@exept.de>
parents: 1017
diff changeset
   100
    "Modified: 26.2.1996 / 17:02:16 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   101
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   102
a27a279701f8 Initial revision
claus
parents:
diff changeset
   103
basicAt:index put:aCharacter
1230
c349c4e9e594 commentary
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
   104
    "store the argument, aCharacter at position index, an Integer.
c349c4e9e594 commentary
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
   105
     Returns aCharacter (sigh).
73
a6640cc96199 *** empty log message ***
claus
parents: 63
diff changeset
   106
     - reimplemented here since we store 16-bit characters"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   107
8094
d05f69bd0097 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 5761
diff changeset
   108
    super basicAt:index put:aCharacter codePoint.
63
1f0cdefb013f *** empty log message ***
claus
parents: 33
diff changeset
   109
    ^ aCharacter
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   110
1230
c349c4e9e594 commentary
Claus Gittinger <cg@exept.de>
parents: 1214
diff changeset
   111
    "Modified: 19.4.1996 / 11:16:22 / cg"
14123
a33fc6cc4332 added: #unsignedShortAt:
Stefan Vogel <sv@exept.de>
parents: 10223
diff changeset
   112
!
a33fc6cc4332 added: #unsignedShortAt:
Stefan Vogel <sv@exept.de>
parents: 10223
diff changeset
   113
a33fc6cc4332 added: #unsignedShortAt:
Stefan Vogel <sv@exept.de>
parents: 10223
diff changeset
   114
unsignedShortAt:index
a33fc6cc4332 added: #unsignedShortAt:
Stefan Vogel <sv@exept.de>
parents: 10223
diff changeset
   115
    "return the short at position index, an Integer"
a33fc6cc4332 added: #unsignedShortAt:
Stefan Vogel <sv@exept.de>
parents: 10223
diff changeset
   116
a33fc6cc4332 added: #unsignedShortAt:
Stefan Vogel <sv@exept.de>
parents: 10223
diff changeset
   117
    ^ super basicAt:index.
1014
da30760cfd3e dummy encoding support
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   118
! !
da30760cfd3e dummy encoding support
Claus Gittinger <cg@exept.de>
parents: 996
diff changeset
   119
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   120
!TwoByteString methodsFor:'encoding'!
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   121
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   122
utf8Encoded
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   123
    "Return my UTF-8 representation as a new String"
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   124
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   125
    self containsNon7BitAscii ifTrue:[
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   126
        ^ self basicUtf8Encoded.
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   127
    ].
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   128
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   129
    ^ self asSingleByteString.
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   130
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   131
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   132
    "
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   133
        'abcdef' asUnicode16String utf8Encoded
18586
b8798de459f4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18576
diff changeset
   134
        'abcdefäöü' asUnicode16String utf8Encoded
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   135
    "
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   136
!
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   137
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   138
utf8EncodedOn:aStream
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   139
    "write to aStream in utf8 encoding"
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   140
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   141
    self containsNon7BitAscii ifTrue:[
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   142
        aStream nextPutAllUtf8:self.
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   143
    ] ifFalse:[
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   144
        |sz "{Class: SmallInteger}"|
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   145
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   146
        sz := self size.
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   147
        1 to:sz do:[:idx|
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   148
            aStream nextPut:(self basicAt:idx).
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   149
        ].
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   150
    ].
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   151
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   152
    "
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   153
     String streamContents:[:w|
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   154
        'abcde1234' asUnicode16String utf8EncodedOn:w
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   155
     ].
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   156
     String streamContents:[:w|
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   157
         'abcdeäöüß' asUnicode16String utf8EncodedOn:w
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   158
     ].
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   159
    "
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   160
! !
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   161
16750
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   162
!TwoByteString methodsFor:'filling and replacing'!
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   163
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   164
replaceFrom:start to:stop with:aString startingAt:repStart
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   165
    "replace the characters starting at index start, anInteger and ending
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   166
     at stop, anInteger with characters from aString starting at repStart.
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   167
     Return the receiver.
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   168
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   169
     - reimplemented here for speed"
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   170
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   171
%{  /* NOCONTEXT */
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   172
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   173
#ifndef NO_PRIM_STRING
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   174
    if (__bothSmallInteger(start, stop)) {
18576
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   175
        int len;
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   176
        int index1 = __intVal(start);
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   177
        int index2 = __intVal(stop);
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   178
        int count = index2 - index1 + 1;
16750
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   179
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   180
        if (count <= 0) {
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   181
             RETURN (self);
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   182
        }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   183
        len = __twoByteStringSize(self);
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   184
        if ((index2 <= len) && (index1 > 0)) {
18576
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   185
            int repIndex = __intVal(repStart);
16750
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   186
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   187
            if (__isStringLike(aString)) {
18576
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   188
                int repLen = __stringSize(aString);
16750
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   189
                if ((repIndex > 0) && ((repIndex + count - 1) <= repLen)) {
18576
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   190
                    REGISTER unsigned char *srcp = __stringVal(aString) + repIndex - 1;
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   191
                    REGISTER unsigned short *dstp  = __twoByteStringVal(self) + index1 - 1;
16750
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   192
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   193
                    while (count-- > 0) {
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   194
                        *dstp++ = *srcp++;
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   195
                    }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   196
                    RETURN (self);
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   197
                }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   198
            } else  if (__isTwoByteString(aString) || __isUnicode16String(aString)) {
18576
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   199
                int repLen = __twoByteStringSize(aString);
16750
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   200
                if ((repIndex > 0) && ((repIndex + count - 1) <= repLen)) {
18576
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   201
                    REGISTER unsigned short *srcp  = __twoByteStringVal(aString) + repIndex - 1;
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   202
                    REGISTER unsigned short *dstp = __twoByteStringVal(self) + index1 - 1;
16750
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   203
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   204
                    if (aString == self) {
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   205
                        /* take care of overlapping copy */
18576
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   206
                        memmove(dstp, srcp, count*sizeof(short));
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   207
                        RETURN (self);
16750
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   208
                    }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   209
                    if (count > 5) {
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   210
                        memcpy(dstp, srcp, count*sizeof(short));
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   211
                    } else {
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   212
                        while (count-- > 0) {
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   213
                            *dstp++ = *srcp++;
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   214
                        }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   215
                    }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   216
                    RETURN (self);
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   217
                }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   218
            }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   219
        }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   220
    }
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   221
#endif
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   222
%}.
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   223
    "/ arrive here if any index arg is out o range, or the source is neither a string,
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   224
    "/ nor a two-byte string.
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   225
    ^ super replaceFrom:start to:stop with:aString startingAt:repStart
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   226
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   227
    "
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   228
     'hello world' asUnicode16String replaceFrom:1 to:5 with:'123456' startingAt:2
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   229
     'hello world' asUnicode16String replaceFrom:1 to:5 with:'123456' asUnicode16String startingAt:2
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   230
     'hello world' asUnicode16String replaceFrom:1 to:0 with:'123456' startingAt:2
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   231
     'hello' asUnicode16String replaceFrom:1 to:6 with:'123456' startingAt:2
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   232
     'hello world' asUnicode16String replaceFrom:1 to:1 with:'123456' startingAt:2
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   233
    "
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   234
! !
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   235
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   236
!TwoByteString methodsFor:'queries'!
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   237
1017
2665a2628779 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   238
bitsPerCharacter
1239
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
   239
    "return the number of bits each character has.
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
   240
     Here, 16 is returned (storing double byte characters)."
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
   241
1017
2665a2628779 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1014
diff changeset
   242
    ^ 16
1239
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
   243
91a688ac83de commentary
Claus Gittinger <cg@exept.de>
parents: 1230
diff changeset
   244
    "Modified: 20.4.1996 / 23:08:38 / cg"
14557
427740fc4329 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 14123
diff changeset
   245
!
427740fc4329 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 14123
diff changeset
   246
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   247
characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   248
    "answer the size in bits of my largest character (actually only 7, 8 or 16)"
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   249
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   250
%{  /* NOCONTEXT */
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   251
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   252
    REGISTER unsigned short *sp = __twoByteStringVal(self);
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   253
    REGISTER unsigned short *last = sp + __twoByteStringSize(self);
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   254
    OBJ cls = __qClass(self);
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   255
    int has8BitChars = 0;
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   256
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   257
    if (cls != Unicode16String && cls != TwoByteString) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   258
        sp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)) / 2;
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   259
    }
18586
b8798de459f4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18576
diff changeset
   260
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   261
#if __POINTER_SIZE__ == 8
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   262
    if (sizeof(unsigned INT) == 8) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   263
        if (!has8BitChars) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   264
            for ( ; (sp+4) <= last; sp += 4) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   265
                if (*(unsigned INT *)sp & 0xFF80FF80FF80FF80) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   266
                    /* there are at least 8-bit chars - check for more */
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   267
                    has8BitChars = 1;
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   268
                    break;
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   269
                }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   270
            }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   271
        }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   272
        for ( ; (sp+4) <= last; sp += 4) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   273
            if (*(unsigned INT *)sp & 0xFF00FF00FF00FF00) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   274
                RETURN(__mkSmallInteger(16));
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   275
            }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   276
        }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   277
    }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   278
#endif
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   279
    if (sizeof(unsigned int) == 4) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   280
        if (!has8BitChars) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   281
            for ( ; (sp+2) <= last; sp += 2) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   282
                if (*(unsigned int *)sp & 0xFF80FF80) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   283
                    /* there are at least 8-bit chars - check for more */
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   284
                    has8BitChars = 1;
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   285
                    break;
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   286
                }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   287
            }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   288
        }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   289
        for ( ; (sp+2) <= last; sp += 2) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   290
            if (*(unsigned int *)sp & 0xFF00FF00) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   291
                RETURN(__mkSmallInteger(16));
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   292
            }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   293
        }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   294
    }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   295
    if (!has8BitChars) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   296
        for ( ; sp < last; sp++) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   297
            if (*sp & 0xFF80) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   298
                /* there are at least 8-bit chars - check for more */
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   299
                has8BitChars = 1;
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   300
                break;
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   301
            }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   302
        }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   303
    }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   304
    for ( ; sp < last; sp++) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   305
        if (*sp & 0xFF00) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   306
            RETURN(__mkSmallInteger(16));
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   307
        }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   308
    }
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   309
    RETURN (__mkSmallInteger(has8BitChars ? 8 : 7));
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   310
%}.
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   311
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   312
    "
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   313
     'hello world' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   314
     'hello worldüäö' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   315
     'a' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   316
     'ü' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   317
     'aa' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   318
     'aü' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   319
     'aaa' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   320
     'aaü' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   321
     'aaaü' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   322
     'aaaa' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   323
     'aaaaü' asUnicode16String characterSize
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   324
    "
18586
b8798de459f4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18576
diff changeset
   325
!
b8798de459f4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18576
diff changeset
   326
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   327
containsNon7BitAscii
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   328
    "return true, if the underlying string contains 8BitCharacters (or widers)
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   329
     (i.e. if it is non-ascii)"
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   330
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   331
%{  /* NOCONTEXT */
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   332
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   333
    REGISTER unsigned short *sp = __twoByteStringVal(self);
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   334
    REGISTER unsigned short *last = sp + __twoByteStringSize(self);
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   335
    OBJ cls = __qClass(self);
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   336
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   337
    if ( cls != Unicode16String && cls != TwoByteString) {
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   338
        sp += __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)) / 2;
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   339
    }
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   340
#if __POINTER_SIZE__ == 8
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   341
    if (sizeof(unsigned INT) == 8) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   342
        for ( ; (sp+4) <= last; sp += 4) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   343
            if (*(unsigned INT *)sp & 0xFF80FF80FF80FF80) {
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   344
                RETURN ( true );
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   345
            }
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   346
        }
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   347
    }
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   348
#endif
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   349
    if (sizeof(unsigned int) == 4) {
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   350
        for ( ; (sp+2) <= last; sp += 2) {
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   351
            if (*(unsigned int *)sp & 0xFF80FF80) {
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   352
                RETURN ( true );
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   353
            }
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   354
        }
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   355
    }
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   356
    for ( ; sp < last; sp++) {
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   357
        if (*sp & 0xFF80) {
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   358
            RETURN ( true );
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   359
        }
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   360
    }
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   361
    RETURN (false);
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   362
%}.
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   363
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   364
    "
18593
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   365
     'hello world' asUnicode16String containsNon7BitAscii
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   366
     'hello worldüäö' asUnicode16String containsNon7BitAscii
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   367
     'ü' asUnicode16String containsNon7BitAscii
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   368
     'aü' asUnicode16String containsNon7BitAscii
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   369
     'aaü' asUnicode16String containsNon7BitAscii
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   370
     'aaaü' asUnicode16String containsNon7BitAscii
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   371
     'aaaaü' asUnicode16String containsNon7BitAscii
e69a425e3823 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 18586
diff changeset
   372
     'aaaaa' asUnicode16String containsNon7BitAscii
17621
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   373
    "
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   374
!
098adea6b2d4 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 16750
diff changeset
   375
14557
427740fc4329 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 14123
diff changeset
   376
isWideString
427740fc4329 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 14123
diff changeset
   377
    ^ true
608
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   378
! !
cd5ac440fa95 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   379
631
d43deb0ec558 version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   380
!TwoByteString class methodsFor:'documentation'!
d43deb0ec558 version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   381
d43deb0ec558 version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   382
version
18576
724284508398 class: TwoByteString
Stefan Vogel <sv@exept.de>
parents: 17621
diff changeset
   383
    ^ '$Header$'
631
d43deb0ec558 version at the end
Claus Gittinger <cg@exept.de>
parents: 608
diff changeset
   384
! !
8094
d05f69bd0097 Use #codePoint instead of deprecated #asciiValue
Stefan Vogel <sv@exept.de>
parents: 5761
diff changeset
   385
16750
394404a33691 class: TwoByteString
Claus Gittinger <cg@exept.de>
parents: 14557
diff changeset
   386
996
560a05298da9 I really store shorts ...
Claus Gittinger <cg@exept.de>
parents: 992
diff changeset
   387
TwoByteString initialize!