author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 05 May 2012 22:58:24 +0100 | |
branch | jv |
changeset 17940 | 985e22966acb |
parent 17938 | e2aad1d7c317 |
child 18011 | deb0c3355881 |
permissions | -rw-r--r-- |
7946 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
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 |
" |
|
10223
761e2a050b69
twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents:
9648
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
7946 | 13 |
|
17938 | 14 |
TwoByteString subclass:#Unicode16String |
7946 | 15 |
instanceVariableNames:'' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Collections-Text' |
|
19 |
! |
|
20 |
||
21 |
!Unicode16String class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
||
35 |
||
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
10223
761e2a050b69
twoByteString moved (req'd in VM)
Claus Gittinger <cg@exept.de>
parents:
9648
diff
changeset
|
41 |
Represents 16-bit (2-byte) Unicode strings. |
7946 | 42 |
" |
43 |
! ! |
|
44 |
||
45 |
!Unicode16String class methodsFor:'initialization'! |
|
46 |
||
47 |
initialize |
|
48 |
"initialize the class - private" |
|
49 |
||
7949 | 50 |
self flags:(Behavior flagWords). |
51 |
||
52 |
Smalltalk at:#UnicodeString put:Unicode16String. |
|
7946 | 53 |
|
54 |
" |
|
55 |
Unicode16String initialize |
|
56 |
" |
|
57 |
||
58 |
"Created: 30.6.1997 / 15:35:52 / cg" |
|
59 |
"Modified: 30.6.1997 / 15:39:21 / cg" |
|
60 |
! ! |
|
61 |
||
11323 | 62 |
!Unicode16String class methodsFor:'reading'! |
63 |
||
64 |
readFrom:aStreamOrString onError:exceptionBlock |
|
65 |
"read & return the next String from the (character-)stream aStream; |
|
66 |
skipping all whitespace first; return the value of exceptionBlock, |
|
67 |
if no string can be read. The sequence of characters as read from the |
|
68 |
stream must be one as stored via storeOn: or storeString." |
|
69 |
||
70 |
" |
|
71 |
this method is not to be inherited |
|
72 |
(i.e. not ok for subclasses; Symbol, for example) |
|
73 |
" |
|
74 |
self ~~ Unicode16String ifTrue:[ |
|
75 |
^ super readFrom:aStreamOrString onError:exceptionBlock |
|
76 |
]. |
|
77 |
^ self readSmalltalkStringFrom:aStreamOrString onError:exceptionBlock |
|
78 |
||
79 |
" |
|
17892 | 80 |
self readFrom:'abc' storeString |
11323 | 81 |
" |
82 |
! ! |
|
83 |
||
7946 | 84 |
!Unicode16String methodsFor:'conversion'! |
85 |
||
86 |
asSymbolIfInterned |
|
9232 | 87 |
"If a symbol with the receivers characters is already known, return it. Otherwise, return nil. |
88 |
Because ST/X does not support non-8-bit symbols, this method |
|
8942 | 89 |
has been redefined to only return a symbol, if the receiver does NOT contain |
90 |
any non-8 bit characters." |
|
91 |
||
7946 | 92 |
|s| |
93 |
||
17938 | 94 |
[ |
7946 | 95 |
s := self asSingleByteString. |
17938 | 96 |
] on:Error do:[:ex| |
97 |
^ nil. |
|
7946 | 98 |
]. |
99 |
^ s asSymbolIfInterned |
|
17938 | 100 |
|
101 |
" |
|
102 |
(Unicode16String with:(Character value:16rFFFF)) asSymbolIfInterned |
|
103 |
'new' asUnicodeString asSymbolIfInterned |
|
104 |
" |
|
7946 | 105 |
! |
106 |
||
8294
ba5f4421848f
Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents:
8049
diff
changeset
|
107 |
asUnicode16String |
8942 | 108 |
"as the receiver already is a unicode-16 string, return it" |
109 |
||
8294
ba5f4421848f
Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents:
8049
diff
changeset
|
110 |
^ self |
ba5f4421848f
Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents:
8049
diff
changeset
|
111 |
! |
ba5f4421848f
Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents:
8049
diff
changeset
|
112 |
|
7946 | 113 |
asUnicodeString |
8942 | 114 |
"as the receiver already is a unicode string, return it" |
115 |
||
7946 | 116 |
^ self |
117 |
! ! |
|
118 |
||
8049
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
119 |
!Unicode16String methodsFor:'printing & storing'! |
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
120 |
|
17940 | 121 |
displayOn:aGCOrStream |
122 |
"display myself as on aStream. |
|
123 |
You must use an ISO10646 unicode font to display this string" |
|
124 |
||
125 |
(aGCOrStream isStream or:[aGCOrStream == Transcript]) ifTrue:[ |
|
126 |
aGCOrStream |
|
127 |
nextPut:$'; |
|
128 |
nextPutAllUnicode:self; |
|
129 |
nextPut:$'. |
|
130 |
^ self |
|
131 |
]. |
|
132 |
^ super displayOn:aGCOrStream |
|
133 |
! |
|
134 |
||
11323 | 135 |
printOn:aStream |
136 |
"print the receiver on aStream. |
|
17921 | 137 |
Let aStream decide how to represent this, whether utf8, ucs16, ..." |
11323 | 138 |
|
139 |
aStream nextPutAllUnicode:self |
|
17921 | 140 |
|
141 |
"Modified (comment): / 25-01-2012 / 10:28:34 / cg" |
|
11323 | 142 |
! |
143 |
||
144 |
storeOn:aStream |
|
145 |
"put the storeString of myself on aStream" |
|
146 |
||
17892 | 147 |
(self utf8Encoded storeOn:aStream). |
148 |
aStream nextPutAll:' utf8Decoded'. |
|
149 |
||
150 |
"/ aStream nextPut:$'. |
|
151 |
"/ (self includes:$') ifTrue:[ |
|
152 |
"/ self do:[:thisChar | |
|
153 |
"/ (thisChar == $') ifTrue:[aStream nextPut:thisChar]. |
|
154 |
"/ aStream nextPutUnicode:thisChar |
|
155 |
"/ ] |
|
156 |
"/ ] ifFalse:[ |
|
157 |
"/ aStream nextPutAllUnicode:self |
|
158 |
"/ ]. |
|
159 |
"/ aStream nextPut:$' |
|
160 |
||
161 |
"Modified: / 28-09-2011 / 16:17:38 / cg" |
|
11323 | 162 |
! |
163 |
||
8049
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
164 |
storeString |
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
165 |
"return a String for storing myself" |
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
166 |
|
17892 | 167 |
"/ ^ self basicStoreString. |
17921 | 168 |
"/ ^ (self withCEscapes storeString),' withoutCEscapes'. |
17892 | 169 |
^ (self utf8Encoded storeString),' utf8Decoded'. |
170 |
||
17921 | 171 |
"Modified: / 25-01-2012 / 11:59:34 / cg" |
17940 | 172 |
! |
173 |
||
174 |
unicodeStoreOn:aStream |
|
175 |
"put the storeString of myself on aStream" |
|
176 |
||
177 |
aStream nextPut:$'. |
|
178 |
(self includes:$') ifTrue:[ |
|
179 |
self do:[:thisChar | |
|
180 |
(thisChar == $') ifTrue:[aStream nextPut:thisChar]. |
|
181 |
aStream nextPutUnicode:thisChar |
|
182 |
] |
|
183 |
] ifFalse:[ |
|
184 |
aStream nextPutAllUnicode:self |
|
185 |
]. |
|
186 |
aStream nextPut:$' |
|
187 |
! |
|
188 |
||
189 |
unicodeStoreString |
|
190 |
"return a UnicodeString for storing myself. |
|
191 |
This method is a kind of kludge. |
|
192 |
Use it when you want to write a storeString to an encoded Stream" |
|
193 |
||
194 |
^ self basicStoreString. |
|
8049
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
195 |
! ! |
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
196 |
|
17940 | 197 |
!Unicode16String methodsFor:'testing'! |
198 |
||
199 |
isUnicode16String |
|
200 |
^ true |
|
201 |
! |
|
202 |
||
203 |
isUnicodeString |
|
204 |
^ true |
|
205 |
! ! |
|
206 |
||
207 |
||
7946 | 208 |
!Unicode16String class methodsFor:'documentation'! |
209 |
||
210 |
version |
|
17940 | 211 |
^ '$Header: /cvs/stx/stx/libbasic/Unicode16String.st,v 1.19 2012/04/24 14:56:53 stefan Exp $' |
17761
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
212 |
! |
b0e5971141bc
Added Lookup and BuiltinLookup classes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17711
diff
changeset
|
213 |
|
17921 | 214 |
version_CVS |
17940 | 215 |
^ '§Header: /cvs/stx/stx/libbasic/Unicode16String.st,v 1.19 2012/04/24 14:56:53 stefan Exp §' |
17927 | 216 |
! |
217 |
||
218 |
version_SVN |
|
17940 | 219 |
^ '$Id: Unicode16String.st 10807 2012-05-05 21:58:24Z vranyj1 $' |
17927 | 220 |
|
7946 | 221 |
! ! |
222 |
||
17846 | 223 |
Unicode16String initialize! |