author | Stefan Vogel <sv@exept.de> |
Mon, 02 Apr 2012 18:57:21 +0200 | |
changeset 14075 | 768e6530e9b5 |
parent 13989 | cd15b3b6154a |
child 14121 | fea92d19d1a4 |
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 |
|
14 |
TwoByteString variableWordSubclass:#Unicode16String |
|
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 |
" |
|
80 |
self readFrom:'abcäöü' storeString |
|
81 |
" |
|
82 |
! ! |
|
83 |
||
84 |
||
7946 | 85 |
!Unicode16String methodsFor:'conversion'! |
86 |
||
87 |
asSymbolIfInterned |
|
9232 | 88 |
"If a symbol with the receivers characters is already known, return it. Otherwise, return nil. |
89 |
Because ST/X does not support non-8-bit symbols, this method |
|
8942 | 90 |
has been redefined to only return a symbol, if the receiver does NOT contain |
91 |
any non-8 bit characters." |
|
92 |
||
7946 | 93 |
|s| |
94 |
||
14075 | 95 |
[ |
7946 | 96 |
s := self asSingleByteString. |
14075 | 97 |
] on:Error do:[:ex| |
98 |
^ nil. |
|
7946 | 99 |
]. |
100 |
^ s asSymbolIfInterned |
|
14075 | 101 |
|
102 |
" |
|
103 |
(Unicode16String with:(Character value:16rFFFF)) asSymbolIfInterned |
|
104 |
'new' asUnicodeString asSymbolIfInterned |
|
105 |
" |
|
7946 | 106 |
! |
107 |
||
8294
ba5f4421848f
Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents:
8049
diff
changeset
|
108 |
asUnicode16String |
8942 | 109 |
"as the receiver already is a unicode-16 string, return it" |
110 |
||
8294
ba5f4421848f
Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents:
8049
diff
changeset
|
111 |
^ self |
ba5f4421848f
Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents:
8049
diff
changeset
|
112 |
! |
ba5f4421848f
Define #asUnicode16String and #asUnicode32String
Stefan Vogel <sv@exept.de>
parents:
8049
diff
changeset
|
113 |
|
7946 | 114 |
asUnicodeString |
8942 | 115 |
"as the receiver already is a unicode string, return it" |
116 |
||
7946 | 117 |
^ self |
118 |
! ! |
|
119 |
||
8049
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
120 |
!Unicode16String methodsFor:'printing & storing'! |
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
121 |
|
11323 | 122 |
printOn:aStream |
123 |
"print the receiver on aStream. |
|
13986
c8b952d6139c
comment/format in: #printOn:
Claus Gittinger <cg@exept.de>
parents:
13737
diff
changeset
|
124 |
Let aStream decide how to represent this, whether utf8, ucs16, ..." |
11323 | 125 |
|
126 |
aStream nextPutAllUnicode:self |
|
13986
c8b952d6139c
comment/format in: #printOn:
Claus Gittinger <cg@exept.de>
parents:
13737
diff
changeset
|
127 |
|
c8b952d6139c
comment/format in: #printOn:
Claus Gittinger <cg@exept.de>
parents:
13737
diff
changeset
|
128 |
"Modified (comment): / 25-01-2012 / 10:28:34 / cg" |
11323 | 129 |
! |
130 |
||
131 |
storeOn:aStream |
|
132 |
"put the storeString of myself on aStream" |
|
133 |
||
13737 | 134 |
(self utf8Encoded storeOn:aStream). |
135 |
aStream nextPutAll:' utf8Decoded'. |
|
136 |
||
137 |
"/ aStream nextPut:$'. |
|
138 |
"/ (self includes:$') ifTrue:[ |
|
139 |
"/ self do:[:thisChar | |
|
140 |
"/ (thisChar == $') ifTrue:[aStream nextPut:thisChar]. |
|
141 |
"/ aStream nextPutUnicode:thisChar |
|
142 |
"/ ] |
|
143 |
"/ ] ifFalse:[ |
|
144 |
"/ aStream nextPutAllUnicode:self |
|
145 |
"/ ]. |
|
146 |
"/ aStream nextPut:$' |
|
147 |
||
148 |
"Modified: / 28-09-2011 / 16:17:38 / cg" |
|
11323 | 149 |
! |
150 |
||
8049
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
151 |
storeString |
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
152 |
"return a String for storing myself" |
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
153 |
|
13737 | 154 |
"/ ^ self basicStoreString. |
13989
cd15b3b6154a
backward compatibility storestring
Claus Gittinger <cg@exept.de>
parents:
13988
diff
changeset
|
155 |
"/ ^ (self withCEscapes storeString),' withoutCEscapes'. |
cd15b3b6154a
backward compatibility storestring
Claus Gittinger <cg@exept.de>
parents:
13988
diff
changeset
|
156 |
^ (self utf8Encoded storeString),' utf8Decoded'. |
13737 | 157 |
|
13989
cd15b3b6154a
backward compatibility storestring
Claus Gittinger <cg@exept.de>
parents:
13988
diff
changeset
|
158 |
"Modified: / 25-01-2012 / 11:59:34 / cg" |
8049
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
159 |
! ! |
ccd0e8f26439
printing - migrating towards unicodeSupport in ST-code
Claus Gittinger <cg@exept.de>
parents:
7982
diff
changeset
|
160 |
|
7946 | 161 |
!Unicode16String class methodsFor:'documentation'! |
162 |
||
163 |
version |
|
14075 | 164 |
^ '$Header: /cvs/stx/stx/libbasic/Unicode16String.st,v 1.17 2012-04-02 16:57:21 stefan Exp $' |
13988
81154d310967
use new c-escape string for stroreString
Claus Gittinger <cg@exept.de>
parents:
13986
diff
changeset
|
165 |
! |
81154d310967
use new c-escape string for stroreString
Claus Gittinger <cg@exept.de>
parents:
13986
diff
changeset
|
166 |
|
81154d310967
use new c-escape string for stroreString
Claus Gittinger <cg@exept.de>
parents:
13986
diff
changeset
|
167 |
version_CVS |
14075 | 168 |
^ '$Header: /cvs/stx/stx/libbasic/Unicode16String.st,v 1.17 2012-04-02 16:57:21 stefan Exp $' |
7946 | 169 |
! ! |
170 |
||
171 |
Unicode16String initialize! |