1
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
63
|
13 |
AbstractString subclass:#TwoByteString
|
1
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Collections-Text'
|
|
18 |
!
|
|
19 |
|
|
20 |
TwoByteString comment:'
|
|
21 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
22 |
All Rights Reserved
|
89
|
23 |
'!
|
1
|
24 |
|
89
|
25 |
!TwoByteString class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 1993 by Claus Gittinger
|
|
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 |
version
|
|
42 |
"
|
|
43 |
$Header: /cvs/stx/stx/libbasic/TwoByteString.st,v 1.7 1994-06-02 17:20:13 claus Exp $
|
|
44 |
"
|
|
45 |
!
|
|
46 |
|
|
47 |
documentation
|
|
48 |
"
|
|
49 |
TwoByteStrings are like strings, but storing 16bits per character.
|
|
50 |
The integration of them into the system is not completed ....
|
|
51 |
"
|
|
52 |
! !
|
1
|
53 |
|
|
54 |
!TwoByteString class methodsFor:'instance creation'!
|
|
55 |
|
|
56 |
basicNew:anInteger
|
|
57 |
"return a new empty string with anInteger characters"
|
|
58 |
|
63
|
59 |
^ (super basicNew:(anInteger*2)) atAllPut:(Character space)
|
1
|
60 |
! !
|
|
61 |
|
63
|
62 |
!TwoByteString methodsFor:'queries'!
|
|
63 |
|
|
64 |
basicSize
|
|
65 |
"return the size of the receiver.
|
|
66 |
(i.e. the number of characters in this String)"
|
|
67 |
|
|
68 |
^ super basicSize // 2
|
|
69 |
! !
|
|
70 |
|
1
|
71 |
!TwoByteString methodsFor:'accessing'!
|
|
72 |
|
|
73 |
basicAt:index
|
|
74 |
"return the character at position index, an Integer
|
73
|
75 |
- reimplemented here since we return 16-bit characters"
|
1
|
76 |
|
63
|
77 |
|val i|
|
|
78 |
|
|
79 |
i := (index * 2) - 1.
|
73
|
80 |
"always msb first"
|
|
81 |
val := (super basicAt:(i+1)) + ((super basicAt:i) * 256).
|
63
|
82 |
^ Character value:val
|
1
|
83 |
!
|
|
84 |
|
|
85 |
basicAt:index put:aCharacter
|
|
86 |
"store the argument, aCharacter at position index, an Integer
|
73
|
87 |
- reimplemented here since we store 16-bit characters"
|
1
|
88 |
|
63
|
89 |
|val i|
|
|
90 |
val := aCharacter asciiValue.
|
|
91 |
i := (index * 2) - 1.
|
73
|
92 |
"always msb first"
|
|
93 |
super basicAt:(i+1) put:(val bitAnd:16rFF).
|
|
94 |
super basicAt:i put:(val // 256).
|
63
|
95 |
^ aCharacter
|
1
|
96 |
! !
|