author | Stefan Vogel <sv@exept.de> |
Tue, 10 Jul 2012 09:55:50 +0200 | |
changeset 14172 | 8c2cf2a68116 |
parent 11996 | 3f018d0b8d45 |
child 17489 | 22f6151b5135 |
child 18011 | deb0c3355881 |
permissions | -rw-r--r-- |
8148 | 1 |
" |
2 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
8411 | 3 |
All Rights Reserved |
8148 | 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 |
" |
|
8081 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
14 |
"{ NameSpace: CharacterEncoderImplementations }" |
|
15 |
||
16 |
TwoByteEncoder subclass:#ISO10646_to_UTF8 |
|
17 |
instanceVariableNames:'' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Collections-Text-Encodings' |
|
21 |
! |
|
22 |
||
23 |
!ISO10646_to_UTF8 class methodsFor:'documentation'! |
|
24 |
||
8148 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
8411 | 28 |
All Rights Reserved |
8148 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
8081 | 39 |
examples |
40 |
" |
|
41 |
Encoding (unicode to utf8) |
|
8411 | 42 |
ISO10646_to_UTF8 encodeString:'hello'. |
8297
e7a05a86f280
removed iso8859-chars (for hpux)
Claus Gittinger <cg@exept.de>
parents:
8221
diff
changeset
|
43 |
|
8081 | 44 |
|
8297
e7a05a86f280
removed iso8859-chars (for hpux)
Claus Gittinger <cg@exept.de>
parents:
8221
diff
changeset
|
45 |
Decoding (utf8 to unicode): |
8081 | 46 |
|t| |
47 |
||
8297
e7a05a86f280
removed iso8859-chars (for hpux)
Claus Gittinger <cg@exept.de>
parents:
8221
diff
changeset
|
48 |
t := ISO10646_to_UTF8 encodeString:'Helloś'. |
8411 | 49 |
ISO10646_to_UTF8 decodeString:t. |
8081 | 50 |
" |
51 |
! ! |
|
52 |
||
53 |
!ISO10646_to_UTF8 methodsFor:'encoding & decoding'! |
|
54 |
||
55 |
decode:aCode |
|
56 |
self shouldNotImplement "/ no single byte conversion possible |
|
57 |
! |
|
58 |
||
59 |
decodeString:aStringOrByteCollection |
|
60 |
"given a string in UTF8 encoding, |
|
61 |
return a new string containing the same characters, in 16bit (or more) encoding. |
|
62 |
Returns either a normal String, a TwoByteString or a FourByteString instance. |
|
63 |
Only useful, when reading from external sources. |
|
64 |
This only handles up-to 30bit characters. |
|
65 |
||
8411 | 66 |
If you work a lot with utf8 encoded textFiles, |
8081 | 67 |
this is a first-class candidate for a primitive." |
68 |
||
8411 | 69 |
|sz anyAbove7BitAscii nBitsRequired |
8081 | 70 |
ascii "{ Class: SmallInteger }" |
71 |
byte "{ Class: SmallInteger }" |
|
72 |
s newString idx next6Bits last6Bits |
|
73 |
errorReporter| |
|
74 |
||
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
75 |
"/ avoid creation of new strings |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
76 |
aStringOrByteCollection isString ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
77 |
aStringOrByteCollection contains8BitCharacters ifFalse:[^ aStringOrByteCollection]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
78 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
79 |
|
8773 | 80 |
errorReporter := [:msg | |
81 |
DecodingError newException |
|
82 |
defaultValue:aStringOrByteCollection; |
|
10531
7a799d53e932
changed #decodeString: - proceedable exception
Stefan Vogel <sv@exept.de>
parents:
9928
diff
changeset
|
83 |
raiseRequestWith:aStringOrByteCollection errorString:msg. |
8773 | 84 |
]. |
8081 | 85 |
|
86 |
next6Bits := [ |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
87 |
| byte | |
8411 | 88 |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
89 |
byte := s nextByte. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
90 |
byte isNil ifTrue:[^ errorReporter value:'short utf8 string']. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
91 |
ascii := (ascii bitShift:6) bitOr:(byte bitAnd:2r00111111). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
92 |
(byte bitAnd:2r11000000) ~~ 2r10000000 ifTrue:[ |
14172 | 93 |
^ errorReporter value:'illegal followbyte (next)'. |
94 |
]. |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
95 |
]. |
8081 | 96 |
|
97 |
last6Bits := [ |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
98 |
| a byte | |
8081 | 99 |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
100 |
byte := s nextByte. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
101 |
byte isNil ifTrue:[^ errorReporter value:'short utf8 string']. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
102 |
a := (ascii bitShift:6) bitOr:(byte bitAnd:2r00111111). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
103 |
(a > 16r3FFFFFFF) ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
104 |
"/ ST/X can only represent 30 bit unicode characters. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
105 |
errorReporter value:'unicode character out of range'. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
106 |
a := 16r3FFFFFFF. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
107 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
108 |
ascii := a. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
109 |
(byte bitAnd:2r11000000) ~~ 2r10000000 ifTrue:[ |
14172 | 110 |
^ errorReporter value:'illegal followbyte (last)'. |
111 |
]. |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
112 |
]. |
8081 | 113 |
|
114 |
nBitsRequired := 8. |
|
8411 | 115 |
anyAbove7BitAscii := false. |
8081 | 116 |
sz := 0. |
117 |
s := aStringOrByteCollection readStream. |
|
14172 | 118 |
|
119 |
"first determine the string size" |
|
8081 | 120 |
[s atEnd] whileFalse:[ |
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
121 |
byte := ascii := s nextByte. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
122 |
(byte bitAnd:16r80) ~~ 0 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
123 |
anyAbove7BitAscii := true. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
124 |
(byte bitAnd:2r11100000) == 2r11000000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
125 |
"/ 80 .. 7FF |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
126 |
ascii := (byte bitAnd:2r00011111). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
127 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
128 |
ascii > 16rFF ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
129 |
nBitsRequired := nBitsRequired max:16 |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
130 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
131 |
"/ a strict utf8 decoder does not allow overlong sequences |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
132 |
ascii < 16r80 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
133 |
errorReporter value:'overlong utf8 sequence' |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
134 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
135 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
136 |
(byte bitAnd:2r11110000) == 2r11100000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
137 |
"/ 800 .. FFFF |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
138 |
ascii := (byte bitAnd:2r00001111). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
139 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
140 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
141 |
ascii > 16rFF ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
142 |
nBitsRequired := nBitsRequired max:16 |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
143 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
144 |
ascii < 16r800 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
145 |
errorReporter value:'overlong utf8 sequence' |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
146 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
147 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
148 |
(byte bitAnd:2r11111000) == 2r11110000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
149 |
"/ 10000 .. 1FFFFF |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
150 |
ascii := (byte bitAnd:2r00000111). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
151 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
152 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
153 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
154 |
ascii > 16rFF ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
155 |
ascii > 16rFFFF ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
156 |
nBitsRequired := nBitsRequired max:32 |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
157 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
158 |
nBitsRequired := nBitsRequired max:16 |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
159 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
160 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
161 |
ascii < 16r10000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
162 |
errorReporter value:'overlong utf8 sequence' |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
163 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
164 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
165 |
(byte bitAnd:2r11111100) == 2r11111000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
166 |
"/ 200000 .. 3FFFFFF |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
167 |
ascii := (byte bitAnd:2r00000011). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
168 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
169 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
170 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
171 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
172 |
ascii > 16rFF ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
173 |
ascii > 16rFFFF ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
174 |
nBitsRequired := nBitsRequired max:32 |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
175 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
176 |
nBitsRequired := nBitsRequired max:16 |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
177 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
178 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
179 |
ascii < 200000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
180 |
errorReporter value:'overlong utf8 sequence' |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
181 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
182 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
183 |
(byte bitAnd:2r11111110) == 2r11111100 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
184 |
"/ 4000000 .. 7FFFFFFF |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
185 |
ascii := (byte bitAnd:2r00000001). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
186 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
187 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
188 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
189 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
190 |
last6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
191 |
ascii > 16rFF ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
192 |
ascii > 16rFFFF ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
193 |
nBitsRequired := nBitsRequired max:32 |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
194 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
195 |
nBitsRequired := nBitsRequired max:16 |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
196 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
197 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
198 |
ascii < 16r4000000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
199 |
errorReporter value:'overlong utf8 sequence' |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
200 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
201 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
202 |
errorReporter value:'invalid utf8 encoding' |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
203 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
204 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
205 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
206 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
207 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
208 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
209 |
sz := sz + 1. |
8081 | 210 |
]. |
211 |
nBitsRequired == 8 ifTrue:[ |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
212 |
anyAbove7BitAscii ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
213 |
"/ can return the original string |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
214 |
aStringOrByteCollection isString ifTrue:[^ aStringOrByteCollection]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
215 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
216 |
newString := String uninitializedNew:sz |
8081 | 217 |
] ifFalse:[ |
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
218 |
nBitsRequired <= 16 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
219 |
newString := Unicode16String new:sz |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
220 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
221 |
newString := Unicode32String new:sz |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
222 |
] |
8081 | 223 |
]. |
224 |
||
225 |
next6Bits := [ |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
226 |
|byte| |
8081 | 227 |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
228 |
byte := s nextByte. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
229 |
ascii := (ascii bitShift:6) bitOr:(byte bitAnd:2r00111111). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
230 |
]. |
8081 | 231 |
|
14172 | 232 |
s reset. |
8081 | 233 |
idx := 1. |
14172 | 234 |
|
235 |
"now fill the string" |
|
8081 | 236 |
[s atEnd] whileFalse:[ |
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
237 |
byte := ascii := s nextByte. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
238 |
(byte bitAnd:2r10000000) ~~ 0 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
239 |
(byte bitAnd:2r11100000) == 2r11000000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
240 |
ascii := (byte bitAnd:2r00011111). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
241 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
242 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
243 |
(byte bitAnd:2r11110000) == 2r11100000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
244 |
ascii := (byte bitAnd:2r00001111). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
245 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
246 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
247 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
248 |
(byte bitAnd:2r11111000) == 2r11110000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
249 |
ascii := (byte bitAnd:2r00000111). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
250 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
251 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
252 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
253 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
254 |
(byte bitAnd:2r11111100) == 2r11111000 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
255 |
ascii := (byte bitAnd:2r00000011). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
256 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
257 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
258 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
259 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
260 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
261 |
(byte bitAnd:2r11111110) == 2r11111100 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
262 |
ascii := (byte bitAnd:2r00000001). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
263 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
264 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
265 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
266 |
next6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
267 |
last6Bits value. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
268 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
269 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
270 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
271 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
272 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
273 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
274 |
newString at:idx put:(Character value:ascii). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
275 |
idx := idx + 1. |
8081 | 276 |
]. |
277 |
^ newString |
|
278 |
||
279 |
" |
|
8411 | 280 |
CharacterArray fromUTF8Bytes:#[ 16r41 16r42 ] |
281 |
CharacterArray fromUTF8Bytes:#[ 16rC1 16r02 ] |
|
282 |
CharacterArray fromUTF8Bytes:#[ 16rE0 16r81 16r02 ] |
|
283 |
CharacterArray fromUTF8Bytes:#[ 16rEF 16rBF 16rBF ] |
|
8081 | 284 |
|
285 |
rfc2279 examples: |
|
8411 | 286 |
CharacterArray fromUTF8Bytes:#[ 16r41 16rE2 16r89 16rA2 16rCE 16r91 16r2E ] |
287 |
CharacterArray fromUTF8Bytes:#[ 16rED 16r95 16r9C 16rEA 16rB5 16rAD 16rEC 16r96 16rB4 ] |
|
288 |
CharacterArray fromUTF8Bytes:#[ 16rE6 16r97 16rA5 16rE6 16r9C 16rAC 16rE8 16rAA 16r9E ] |
|
8081 | 289 |
|
290 |
invalid: |
|
8411 | 291 |
CharacterArray fromUTF8Bytes:#[ 16rC0 16r80 ] |
292 |
CharacterArray fromUTF8Bytes:#[ 16rE0 16r80 16r80 ] |
|
8081 | 293 |
" |
9928 | 294 |
|
295 |
"Modified: / 18-09-2006 / 19:55:52 / cg" |
|
8081 | 296 |
! |
297 |
||
298 |
encode:aCode |
|
299 |
self shouldNotImplement "/ no single byte conversion possible |
|
300 |
! |
|
301 |
||
302 |
encodeString:aUnicodeString |
|
303 |
"return the UTF-8 representation of a aUnicodeString. |
|
304 |
The resulting string is only useful to be stored on some external file, |
|
305 |
not for being used inside ST/X. |
|
306 |
||
8411 | 307 |
If you work a lot with utf8 encoded textFiles, |
8081 | 308 |
this is a first-class candidate for a primitive." |
309 |
||
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
310 |
|s| |
8081 | 311 |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
312 |
"/ avoid creation of new strings |
14172 | 313 |
aUnicodeString contains8BitCharacters ifFalse:[^ aUnicodeString asSingleByteString]. |
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
314 |
|
8221 | 315 |
s := WriteStream on:(String uninitializedNew:aUnicodeString size). |
8081 | 316 |
aUnicodeString do:[:eachCharacter | |
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
317 |
|codePoint b1 b2 b3 b4 b5 v "{Class: SmallInteger }"| |
8081 | 318 |
|
8460
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
319 |
codePoint := eachCharacter codePoint. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
320 |
codePoint <= 16r7F ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
321 |
s nextPut:eachCharacter. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
322 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
323 |
b1 := Character value:((codePoint bitAnd:16r3F) bitOr:2r10000000). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
324 |
v := codePoint bitShift:-6. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
325 |
v <= 16r1F ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
326 |
s nextPut:(Character value:(v bitOr:2r11000000)). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
327 |
s nextPut:b1. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
328 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
329 |
b2 := Character value:((v bitAnd:16r3F) bitOr:2r10000000). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
330 |
v := v bitShift:-6. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
331 |
v <= 16r0F ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
332 |
s nextPut:(Character value:(v bitOr:2r11100000)). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
333 |
s nextPut:b2; nextPut:b1. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
334 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
335 |
b3 := Character value:((v bitAnd:16r3F) bitOr:2r10000000). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
336 |
v := v bitShift:-6. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
337 |
v <= 16r07 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
338 |
s nextPut:(Character value:(v bitOr:2r11110000)). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
339 |
s nextPut:b3; nextPut:b2; nextPut:b1. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
340 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
341 |
b4 := Character value:((v bitAnd:16r3F) bitOr:2r10000000). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
342 |
v := v bitShift:-6. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
343 |
v <= 16r03 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
344 |
s nextPut:(Character value:(v bitOr:2r11111000)). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
345 |
s nextPut:b4; nextPut:b3; nextPut:b2; nextPut:b1. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
346 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
347 |
b5 := Character value:((v bitAnd:16r3F) bitOr:2r10000000). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
348 |
v := v bitShift:-6. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
349 |
v <= 16r01 ifTrue:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
350 |
s nextPut:(Character value:(v bitOr:2r11111100)). |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
351 |
s nextPut:b5; nextPut:b4; nextPut:b3; nextPut:b2; nextPut:b1. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
352 |
] ifFalse:[ |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
353 |
"/ cannot happen - we only support up to 30 bit characters |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
354 |
self error:'ascii value > 31bit in utf8Encode'. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
355 |
] |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
356 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
357 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
358 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
359 |
]. |
f4d333135e1d
tuned encoding/decoding (quick check for 8-bit chars)
penk
parents:
8411
diff
changeset
|
360 |
]. |
8081 | 361 |
]. |
362 |
||
363 |
^ s contents |
|
364 |
||
365 |
" |
|
366 |
(self encodeString:'hello') asByteArray #[104 101 108 108 111] |
|
367 |
(self encodeString:(Character value:16r40) asString) asByteArray #[64] |
|
368 |
(self encodeString:(Character value:16r7F) asString) asByteArray #[127] |
|
369 |
(self encodeString:(Character value:16r80) asString) asByteArray #[194 128] |
|
8411 | 370 |
(self encodeString:(Character value:16rFF) asString) asByteArray #[195 191] |
371 |
(self encodeString:(Character value:16r100) asString) asByteArray #[196 128] |
|
372 |
(self encodeString:(Character value:16r200) asString) asByteArray #[200 128] |
|
373 |
(self encodeString:(Character value:16r400) asString) asByteArray #[208 128] |
|
374 |
(self encodeString:(Character value:16r800) asString) asByteArray #[224 160 128] |
|
375 |
(self encodeString:(Character value:16r1000) asString) asByteArray #[225 128 128] |
|
376 |
(self encodeString:(Character value:16r2000) asString) asByteArray #[226 128 128] |
|
377 |
(self encodeString:(Character value:16r4000) asString) asByteArray #[228 128 128] |
|
378 |
(self encodeString:(Character value:16r8000) asString) asByteArray #[232 128 128] |
|
379 |
(self encodeString:(Character value:16rFFFF) asString) asByteArray #[239 191 191] |
|
8081 | 380 |
" |
381 |
! ! |
|
382 |
||
11974 | 383 |
!ISO10646_to_UTF8 privateMethodsFor:'queries'! |
384 |
||
385 |
bytesToReadFor:firstByte |
|
386 |
|bytesToRead| |
|
387 |
||
388 |
bytesToRead := 1. |
|
389 |
(firstByte isBitSet:8) ifFalse:[^1]. |
|
390 |
7 downTo:3 |
|
391 |
do:[:idx | |
|
392 |
(firstByte isBitSet:idx) ifTrue:[ |
|
393 |
bytesToRead := bytesToRead + 1 |
|
394 |
] ifFalse:[ |
|
395 |
^bytesToRead |
|
396 |
] |
|
397 |
]. |
|
398 |
^bytesToRead |
|
399 |
||
400 |
"Created: / 14-06-2005 / 17:17:24 / janfrog" |
|
401 |
! ! |
|
402 |
||
8163 | 403 |
!ISO10646_to_UTF8 methodsFor:'queries'! |
404 |
||
11974 | 405 |
characterSize:charOrcodePoint |
406 |
"return the number of bytes required to encode codePoint" |
|
407 |
||
408 |
"Taken from RFC 3629" |
|
409 |
||
410 |
(charOrcodePoint asInteger between:16r00000000 and:16r0000007F) ifTrue:[^1]. |
|
411 |
(charOrcodePoint asInteger between:16r00000080 and:16r000007FF) ifTrue:[^2]. |
|
412 |
(charOrcodePoint asInteger between:16r00000800 and:16r0000FFFF) ifTrue:[^3]. |
|
413 |
(charOrcodePoint asInteger between:16r00010000 and:16r0010FFFF) ifTrue:[^4]. |
|
414 |
||
415 |
^self error:'Invalid codePoint' |
|
416 |
||
417 |
"Created: / 15-06-2005 / 15:16:22 / janfrog" |
|
418 |
! |
|
419 |
||
8163 | 420 |
nameOfEncoding |
14172 | 421 |
^ #utf8 |
8163 | 422 |
! ! |
423 |
||
11974 | 424 |
!ISO10646_to_UTF8 methodsFor:'stream support'! |
425 |
||
426 |
readNext:charactersToRead charactersFrom:stream |
|
11996 | 427 |
|
11974 | 428 |
| s | |
429 |
||
430 |
s := (String new:charactersToRead) writeStream. |
|
431 |
charactersToRead timesRepeat:[ |
|
432 |
| c | |
|
433 |
c := stream peek. |
|
434 |
s nextPutAll:(stream next:(self bytesToReadFor:c)) |
|
435 |
]. |
|
436 |
^ self decodeString:s contents |
|
437 |
||
438 |
"Created: / 16-06-2005 / 11:45:14 / masca" |
|
439 |
! |
|
440 |
||
441 |
readNextCharacterFrom:aStream |
|
11996 | 442 |
|
11974 | 443 |
|firstByte bytesToRead str| |
444 |
||
445 |
firstByte := aStream peek. |
|
446 |
firstByte ifNil:[^nil]. |
|
447 |
firstByte := firstByte asInteger. |
|
448 |
bytesToRead := self bytesToReadFor:firstByte. |
|
449 |
str := self decodeString:(aStream next:bytesToRead). |
|
450 |
str size > 1 ifTrue:[ |
|
451 |
self error:'Badly coded method' |
|
452 |
]. |
|
453 |
^ str first |
|
454 |
||
455 |
"Created: / 14-06-2005 / 17:03:59 / janfrog" |
|
456 |
! ! |
|
457 |
||
8081 | 458 |
!ISO10646_to_UTF8 class methodsFor:'documentation'! |
459 |
||
460 |
version |
|
14172 | 461 |
^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__ISO10646_to_UTF8.st,v 1.17 2012-07-10 07:55:50 stefan Exp $' |
8081 | 462 |
! ! |