author | Claus Gittinger <cg@exept.de> |
Wed, 16 Sep 2009 21:22:24 +0200 | |
changeset 11956 | ca9071118979 |
parent 11933 | ce0e593cb8f1 |
child 13499 | 23793f3a7025 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
154 | 3 |
All Rights Reserved |
1 | 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 |
" |
|
5407 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
1 | 14 |
Magnitude subclass:#Character |
995
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
15 |
instanceVariableNames:'asciivalue' |
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
16 |
classVariableNames:'CharacterTable' |
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
17 |
poolDictionaries:'' |
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
18 |
category:'Magnitude-General' |
1 | 19 |
! |
20 |
||
2124 | 21 |
!Character class methodsFor:'documentation'! |
54 | 22 |
|
88 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
154 | 26 |
All Rights Reserved |
88 | 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 |
||
54 | 37 |
documentation |
38 |
" |
|
1491
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
39 |
This class represents characters. |
7897 | 40 |
|
1491
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
41 |
Notice, that actual character objects are not used when characters |
9153 | 42 |
are stored in strings, symbols etc; |
8028 | 43 |
these only store a character's asciiValue/codePoint for a more compact representation. |
1491
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
44 |
The word 'asciiValue' is a historic leftover - actually, any integer |
8028 | 45 |
code is allowed and actually used (i.e. characters are not limited to 8bit). |
46 |
||
9153 | 47 |
Single byte Characters are unique; i.e. for every asciiValue (0..255) there exists exactly |
48 |
one instance of Character, which is shared |
|
8028 | 49 |
(Character value:xxx checks for this, and returns a reference to an existing instance). |
9153 | 50 |
Other characters (i.e. asciivalue > 255) are not guaranteed to be shared; |
8028 | 51 |
i.e. these might be created as required (actually, do NOT depend on which characters are and |
52 |
which are not shared; always compare using #= if there is any chance of a non-ascii character |
|
53 |
being involved. |
|
9153 | 54 |
|
1229 | 55 |
This means: you may compare characters using #== ONLY IFF you are certain, |
9153 | 56 |
that the characters ranges is 0..255. |
8028 | 57 |
Otherwise, you HAVE TO compare using #=. (if in doubt, always compare using #=). |
1491
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
58 |
Sorry for this inconvenience, but it is (practically) impossible to keep |
8028 | 59 |
the possible maximum of 2^32 characters (Unicode) around, for that convenience alone. |
1491
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
60 |
|
357 | 61 |
|
68 | 62 |
Methods marked as (JS) come from the manchester Character goody |
63 |
(CharacterComparing) by Jan Steinman, which allow Characters to be used as |
|
9153 | 64 |
Interval elements (i.e. ($a to:$z) do:[...] ); |
1229 | 65 |
They are not a big deal, but convenient add-ons. |
66 |
Some of these have been modified a bit. |
|
1 | 67 |
|
68 | 68 |
WARNING: characters are known by compiler and runtime system - |
11933 | 69 |
do not change the instance layout. |
357 | 70 |
|
71 |
Also, although you can create subclasses of Character, the compiler always |
|
72 |
creates instances of Character for literals ... |
|
814
d4d28ca7afcd
made the global CharacterTable a classVar of Character
Claus Gittinger <cg@exept.de>
parents:
760
diff
changeset
|
73 |
... and other classes are hard-wired to always return instances of characters |
357 | 74 |
in some cases (i.e. String>>at:, Symbol>>at: etc.). |
75 |
Therefore, it may not make sense to create a character-subclass. |
|
1295 | 76 |
|
8028 | 77 |
Case Mapping in Unicode: |
11933 | 78 |
There are a number of complications to case mappings that occur once the repertoire |
79 |
of characters is expanded beyond ASCII. |
|
80 |
||
81 |
* Because of the inclusion of certain composite characters for compatibility, |
|
82 |
such as U+01F1 'DZ' capital dz, there is a third case, called titlecase, |
|
83 |
which is used where the first letter of a word is to be capitalized |
|
84 |
(e.g. Titlecase, vs. UPPERCASE, or lowercase). |
|
85 |
For example, the title case of the example character is U+01F2 'Dz' capital d with small z. |
|
86 |
||
87 |
* Case mappings may produce strings of different length than the original. |
|
88 |
For example, the German character U+00DF small letter sharp s expands when uppercased to |
|
89 |
the sequence of two characters 'SS'. |
|
90 |
This also occurs where there is no precomposed character corresponding to a case mapping. |
|
91 |
*** This is not yet implemented (in 5.2) *** |
|
92 |
||
93 |
* Characters may also have different case mappings, depending on the context. |
|
94 |
For example, U+03A3 capital sigma lowercases to U+03C3 small sigma if it is not followed |
|
95 |
by another letter, but lowercases to 03C2 small final sigma if it is. |
|
96 |
*** This is not yet implemented (in 5.2) *** |
|
97 |
||
98 |
* Characters may have case mappings that depend on the locale. |
|
99 |
For example, in Turkish the letter 0049 'I' capital letter i lowercases to 0131 small dotless i. |
|
100 |
*** This is not yet implemented (in 5.2) *** |
|
101 |
||
102 |
* Case mappings are not, in general, reversible. |
|
103 |
For example, once the string 'McGowan' has been uppercased, lowercased or titlecased, |
|
104 |
the original cannot be recovered by applying another uppercase, lowercase, or titlecase operation. |
|
8028 | 105 |
|
106 |
Collation Sequence: |
|
11933 | 107 |
*** This is not yet implemented (in 5.2) *** |
8028 | 108 |
|
1295 | 109 |
[author:] |
11933 | 110 |
Claus Gittinger |
1295 | 111 |
|
112 |
[see also:] |
|
11933 | 113 |
String TwoByteString Unicode16String Unicode32String |
114 |
StringCollection Text |
|
54 | 115 |
" |
116 |
! ! |
|
1 | 117 |
|
2124 | 118 |
!Character class methodsFor:'instance creation'! |
1 | 119 |
|
120 |
basicNew |
|
121 |
"catch new - Characters cannot be created with new" |
|
122 |
||
123 |
^ self error:'Characters cannot be created with new' |
|
124 |
! |
|
125 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
126 |
codePoint:anInteger |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
127 |
"return a character with codePoint anInteger" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
128 |
|
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
129 |
%{ /* NOCONTEXT */ |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
130 |
|
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
131 |
INT __codePoint; |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
132 |
|
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
133 |
if (__isSmallInteger(anInteger)) { |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
134 |
__codePoint = __smallIntegerVal(anInteger); |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
135 |
if ((unsigned)(__codePoint) <= MAX_IMMEDIATE_CHARACTER /* (__codePoint >= 0) && (__codePoint <= 255) */) { |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
136 |
RETURN ( __MKCHARACTER(__codePoint) ); |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
137 |
} else { |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
138 |
RETURN ( __MKUCHARACTER(__codePoint) ); |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
139 |
} |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
140 |
} |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
141 |
%}. |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
142 |
(anInteger between:0 and:(CharacterTable size - 1)) ifTrue:[ |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
143 |
^ CharacterTable at:(anInteger + 1) |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
144 |
]. |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
145 |
(anInteger between:16r100 and:16r3FFFFFFF) ifTrue:[ |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
146 |
^ super basicNew setCodePoint:anInteger |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
147 |
]. |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
148 |
" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
149 |
a characters codePoint must be 0..16r3FFFFFFF. |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
150 |
(i.e. only characters with up-to 30 bits are allowed.) |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
151 |
" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
152 |
RangeError raiseWith:anInteger errorString:'invalid codePoint for character' |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
153 |
|
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
154 |
" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
155 |
self codePoint:16r34. |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
156 |
self codePoint:16r3455. |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
157 |
self codePoint:16rFFFFFFFFFFFFFFFFFFF. |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
158 |
" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
159 |
! |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
160 |
|
699 | 161 |
digitValue:anInteger |
162 |
"return a character that corresponds to anInteger. |
|
163 |
0-9 map to $0-$9, 10-35 map to $A-$Z" |
|
164 |
||
165 |
|val "{ Class: SmallInteger }" | |
|
166 |
||
167 |
val := anInteger. |
|
168 |
(val between:0 and:9) ifTrue:[ |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
169 |
^ Character codePoint:(val + ($0 codePoint)) |
699 | 170 |
]. |
171 |
(val between:10 and:35) ifTrue:[ |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
172 |
^ Character codePoint:(val + ($A codePoint - 10)) |
699 | 173 |
]. |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
174 |
^ self error:'value not in range 0 to 35' |
699 | 175 |
! |
176 |
||
6808 | 177 |
utf8DecodeFrom:aStream |
178 |
"read and return a single unicode character from an UTF8 encoded stream" |
|
179 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
180 |
|fetchNext c1 c2 c3 c4 c5 codePoint| |
6808 | 181 |
|
182 |
c1 := aStream next. |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
183 |
codePoint := c1 codePoint. |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
184 |
codePoint <= 16r7F ifTrue:[ |
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
185 |
"/ 0xxxxxxx - 7 bits |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
186 |
^ c1. |
6808 | 187 |
]. |
188 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
189 |
(codePoint bitAnd:2r11000000) == 2r10000000 ifTrue:[ |
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
190 |
"/ out of sync (got an intermediate character) |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
191 |
InvalidEncodingError raiseRequestWith:codePoint errorString:' - out of sync'. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
192 |
^ c1. |
6808 | 193 |
]. |
194 |
||
195 |
fetchNext := [ |ch| |
|
196 |
||
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
197 |
ch := aStream next. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
198 |
(ch codePoint bitAnd:2r11000000) == 2r10000000 ifFalse:[ |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
199 |
"/ followup chars must have 2r10 in high bits |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
200 |
InvalidEncodingError raiseRequestWith:ch codePoint. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
201 |
^ c1. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
202 |
]. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
203 |
ch |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
204 |
]. |
6808 | 205 |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
206 |
(codePoint bitAnd:2r11100000) == 2r11000000 ifTrue:[ |
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
207 |
"/ 110xxxxx 10xxxxxx - 11 bits |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
208 |
c2 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
209 |
codePoint := c1 codePoint bitAnd:16r1F. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
210 |
codePoint := (codePoint bitShift:6) bitOr:(c2 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
211 |
codePoint <= 16r7F ifTrue:[ |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
212 |
InvalidEncodingError raiseRequestWith:codePoint. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
213 |
]. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
214 |
^ Character codePoint:codePoint |
6808 | 215 |
]. |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
216 |
(codePoint bitAnd:2r11110000) == 2r11100000 ifTrue:[ |
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
217 |
"/ 1110xxxx 10xxxxxx 10xxxxxx - 16 bits |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
218 |
c2 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
219 |
c3 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
220 |
codePoint := c1 codePoint bitAnd:16r0F. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
221 |
codePoint := (codePoint bitShift:6) bitOr:(c2 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
222 |
codePoint := (codePoint bitShift:6) bitOr:(c3 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
223 |
codePoint <= 16r7FF ifTrue:[ |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
224 |
InvalidEncodingError raiseRequestWith:codePoint. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
225 |
]. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
226 |
^ Character codePoint:codePoint |
6808 | 227 |
]. |
228 |
||
229 |
"/ notice: currently, characters can only have 16bit encoding; |
|
230 |
"/ therefore the following will raise a runtime exception, |
|
231 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
232 |
(codePoint bitAnd:2r11111000) == 2r11110000 ifTrue:[ |
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
233 |
"/ 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - 21 bits |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
234 |
c2 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
235 |
c3 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
236 |
c4 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
237 |
codePoint := c1 codePoint bitAnd:16r07. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
238 |
codePoint := (codePoint bitShift:6) bitOr:(c2 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
239 |
codePoint := (codePoint bitShift:6) bitOr:(c3 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
240 |
codePoint := (codePoint bitShift:6) bitOr:(c4 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
241 |
codePoint <= 16rFFFF ifTrue:[ |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
242 |
InvalidEncodingError raiseRequestWith:codePoint. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
243 |
]. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
244 |
^ Character codePoint:codePoint |
6808 | 245 |
]. |
246 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
247 |
(codePoint bitAnd:2r11111100) == 2r11111000 ifTrue:[ |
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
248 |
"/ 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx - 26 bits |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
249 |
c2 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
250 |
c3 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
251 |
c4 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
252 |
c5 := fetchNext value. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
253 |
codePoint := c1 codePoint bitAnd:16r03. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
254 |
codePoint := (codePoint bitShift:6) bitOr:(c2 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
255 |
codePoint := (codePoint bitShift:6) bitOr:(c3 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
256 |
codePoint := (codePoint bitShift:6) bitOr:(c4 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
257 |
codePoint := (codePoint bitShift:6) bitOr:(c5 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
258 |
codePoint <= 16r1FFFFF ifTrue:[ |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
259 |
InvalidEncodingError raiseRequestWith:codePoint. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
260 |
]. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
261 |
^ Character codePoint:codePoint |
6808 | 262 |
]. |
263 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
264 |
(codePoint bitAnd:2r11111110) == 2r11111100 ifTrue:[ |
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
265 |
"/ 1111110x ... 10xxxxxx - any number of bits |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
266 |
codePoint := c1 codePoint bitAnd:16r01. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
267 |
|
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
268 |
c2 := aStream peek. |
11328 | 269 |
[ c2 notNil and:[(c2 codePoint bitAnd:2r11000000) == 2r10000000]] whileTrue:[ |
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
270 |
codePoint := (codePoint bitShift:6) bitOr:(c2 codePoint bitAnd:16r3F). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
271 |
aStream next. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
272 |
]. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
273 |
codePoint <= 16r3FFFFFF ifTrue:[ |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
274 |
InvalidEncodingError raiseRequestWith:codePoint. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
275 |
]. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
276 |
^ Character codePoint:codePoint |
6808 | 277 |
]. |
278 |
||
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
279 |
InvalidEncodingError raiseRequestWith:codePoint. |
6808 | 280 |
^ c1 |
281 |
||
282 |
" |
|
9153 | 283 |
Character utf8DecodeFrom:'a' readStream |
284 |
Character utf8DecodeFrom:#[195 188] asString readStream |
|
285 |
" |
|
6808 | 286 |
|
287 |
"test: |
|
288 |
||
289 |
|utf8Encoding original readBack| |
|
290 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
291 |
1 to:16rFFFF do:[:codePoint | |
11325
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
292 |
original := Character value:codePoint. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
293 |
utf8Encoding := original asString utf8Encoded. |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
294 |
readBack := Character utf8DecodeFrom:(utf8Encoding readStream). |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
295 |
readBack codePoint = codePoint ifFalse:[ |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
296 |
self halt |
b2ba4174deb8
Raise InvalidEncodingError when utf8 decode fails
Stefan Vogel <sv@exept.de>
parents:
11321
diff
changeset
|
297 |
] |
6808 | 298 |
] |
299 |
" |
|
300 |
! |
|
301 |
||
1 | 302 |
value:anInteger |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
303 |
"return a character with codePoint anInteger - backward compatibility" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
304 |
|
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
305 |
^ self codePoint:anInteger |
5945 | 306 |
! ! |
307 |
||
2214 | 308 |
!Character class methodsFor:'accessing untypeable characters'! |
309 |
||
310 |
endOfInput |
|
11144 | 311 |
"Answer the Character representing ctrl-d (Unix-EOF)." |
9153 | 312 |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
313 |
^ self codePoint:4 |
2214 | 314 |
! |
315 |
||
316 |
leftParenthesis |
|
8097 | 317 |
"Answer the Character representing a left parenthesis." |
9153 | 318 |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
319 |
^ self codePoint:40 |
2214 | 320 |
! |
321 |
||
322 |
period |
|
8097 | 323 |
"Answer the Character representing a carriage period." |
9153 | 324 |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
325 |
^ self codePoint:46 |
2214 | 326 |
! |
327 |
||
328 |
poundSign |
|
11144 | 329 |
"Answer the Character representing a pound sign (hash)." |
9153 | 330 |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
331 |
^ self codePoint:35 |
2214 | 332 |
! |
333 |
||
334 |
rightParenthesis |
|
8097 | 335 |
"Answer the Character representing a right parenthesis." |
9153 | 336 |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
337 |
^ self codePoint:41 |
2214 | 338 |
! ! |
339 |
||
2124 | 340 |
!Character class methodsFor:'constants'! |
699 | 341 |
|
342 |
backspace |
|
343 |
"return the backspace character" |
|
344 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
345 |
^ Character codePoint:8 |
699 | 346 |
! |
347 |
||
348 |
bell |
|
349 |
"return the bell character" |
|
350 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
351 |
^ Character codePoint:7 |
699 | 352 |
! |
353 |
||
354 |
cr |
|
9153 | 355 |
"return the lineEnd character |
699 | 356 |
- actually (in unix) this is a newline character" |
357 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
358 |
^ Character codePoint:10 |
699 | 359 |
! |
360 |
||
9153 | 361 |
del |
699 | 362 |
"return the delete character" |
363 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
364 |
^ Character codePoint:16r7F |
699 | 365 |
! |
366 |
||
367 |
doubleQuote |
|
368 |
"return the double-quote character" |
|
369 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
370 |
^ Character codePoint:34 |
699 | 371 |
! |
372 |
||
373 |
esc |
|
374 |
"return the escape character" |
|
375 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
376 |
^ Character codePoint:27 |
699 | 377 |
! |
378 |
||
10428 | 379 |
etx |
380 |
"return the end-of-text character" |
|
381 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
382 |
^ Character codePoint:3 |
10428 | 383 |
! |
384 |
||
7688 | 385 |
euro |
7689 | 386 |
"The Euro currency sign (notice: not all fonts support it). |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
387 |
The Unicode encoding is U+20AC" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
388 |
|
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
389 |
^ Character codePoint:16r20AC |
7689 | 390 |
|
391 |
" |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
392 |
Transcript font:(Font family:'courier' size:12 encoding:'iso10646-1'). |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
393 |
Transcript showCR:Character euro |
7976 | 394 |
" |
395 |
" |
|
7689 | 396 |
0 to:255 do:[:i | |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
397 |
Transcript |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
398 |
show:'| '; show:((i printStringRadix:16) leftPaddedTo:2); |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
399 |
show:' | '; show:(i printStringPaddedTo:3); |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
400 |
show:' | '; show:(Character value:i); |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
401 |
cr. |
7689 | 402 |
] |
403 |
" |
|
7688 | 404 |
! |
405 |
||
699 | 406 |
excla |
407 |
"return the exclamation-mark character" |
|
408 |
^ $!! |
|
1 | 409 |
! |
410 |
||
699 | 411 |
ff |
412 |
"return the form-feed character" |
|
413 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
414 |
^ Character codePoint:12 |
699 | 415 |
! |
416 |
||
417 |
lf |
|
418 |
"return the newline/linefeed character" |
|
419 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
420 |
^ Character codePoint:10 |
699 | 421 |
! |
1 | 422 |
|
4340
523ef8410fad
added #linefeed - squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4337
diff
changeset
|
423 |
linefeed |
523ef8410fad
added #linefeed - squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4337
diff
changeset
|
424 |
"squeak compatibility: return the newline/linefeed character" |
523ef8410fad
added #linefeed - squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4337
diff
changeset
|
425 |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
426 |
^ Character codePoint:10 |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
427 |
! |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
428 |
|
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
429 |
maxImmediateCodePoint |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
430 |
"return the maximum codePoint until which the characters are shared" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
431 |
%{ /* NOCONTEXT */ |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
432 |
RETURN(__mkSmallInteger(MAX_IMMEDIATE_CHARACTER)); |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
433 |
%}. |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
434 |
|
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
435 |
" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
436 |
self maxImmediateCodePoint |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
437 |
" |
4340
523ef8410fad
added #linefeed - squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4337
diff
changeset
|
438 |
! |
523ef8410fad
added #linefeed - squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4337
diff
changeset
|
439 |
|
9153 | 440 |
maxValue |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
441 |
"return the maximum codePoint a character may have" |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
442 |
|
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
443 |
^ 16r3FFFFFFF |
699 | 444 |
! |
445 |
||
446 |
newPage |
|
447 |
"return the form-feed character" |
|
448 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
449 |
^ Character codePoint:12 |
699 | 450 |
! |
451 |
||
452 |
nl |
|
453 |
"return the newline character" |
|
68 | 454 |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
455 |
^ Character codePoint:10 |
699 | 456 |
! |
457 |
||
6324 | 458 |
null |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
459 |
^ Character codePoint:0 |
6324 | 460 |
! |
461 |
||
699 | 462 |
quote |
463 |
"return the single-quote character" |
|
464 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
465 |
^ Character codePoint:39 |
699 | 466 |
! |
467 |
||
9153 | 468 |
return |
699 | 469 |
"return the return character. |
470 |
In ST/X, this is different from cr - for Unix reasons." |
|
471 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
472 |
^ Character codePoint:13 |
699 | 473 |
! |
474 |
||
475 |
space |
|
476 |
"return the blank character" |
|
477 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
478 |
^ Character codePoint:32 |
699 | 479 |
! |
480 |
||
481 |
tab |
|
482 |
"return the tabulator character" |
|
483 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
484 |
^ Character codePoint:9 |
1 | 485 |
! ! |
486 |
||
2124 | 487 |
!Character class methodsFor:'primitive input'! |
1 | 488 |
|
489 |
fromUser |
|
357 | 490 |
"return a character from the keyboard (C's standard input stream) |
1 | 491 |
- this should only be used for emergency evaluators and the like." |
492 |
||
493 |
%{ /* NOCONTEXT */ |
|
494 |
int c; |
|
495 |
||
496 |
c = getchar(); |
|
497 |
if (c < 0) { |
|
9153 | 498 |
RETURN (nil); |
1 | 499 |
} |
1133 | 500 |
RETURN ( __MKCHARACTER(c & 0xFF) ); |
5433 | 501 |
%}. |
502 |
^ Stdin next |
|
1 | 503 |
! ! |
504 |
||
2124 | 505 |
!Character class methodsFor:'queries'! |
3 | 506 |
|
4337
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
507 |
allCharacters |
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
508 |
"added for squeak compatibility: return a collection of all chars" |
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
509 |
|
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
510 |
^ CharacterTable |
9153 | 511 |
|
4337
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
512 |
" |
9153 | 513 |
Character allCharacters |
4337
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
514 |
" |
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
515 |
! |
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
516 |
|
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
517 |
hasSharedInstances |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
518 |
"return true if this class has shared instances, that is, instances |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
519 |
with the same value are identical. |
9148 | 520 |
Although not always shared (TwoByte CodePoint-Characters), these should be treated |
521 |
so, to be independent of the number of the underlying implementation" |
|
2672
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2561
diff
changeset
|
522 |
|
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
523 |
^ true |
2672
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2561
diff
changeset
|
524 |
! |
dc3662188b2c
added #hasImmediateInstances for VW compatibility
Claus Gittinger <cg@exept.de>
parents:
2561
diff
changeset
|
525 |
|
3 | 526 |
isBuiltInClass |
1271 | 527 |
"return true if this class is known by the run-time-system. |
528 |
Here, true is returned for myself, false for subclasses." |
|
3 | 529 |
|
530 |
^ self == Character |
|
1271 | 531 |
|
532 |
"Modified: 23.4.1996 / 15:56:39 / cg" |
|
4337
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
533 |
! |
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
534 |
|
8206 | 535 |
isLegalUnicodeCodePoint:anInteger |
536 |
"answer true, if anInteger is a valid unicode code point" |
|
537 |
||
9153 | 538 |
"Range 16rD800 - 16rDFFF is reserved for the |
8207
12131fc77a99
#isLegalUnicodeCodePoint: - Fix comment
Stefan Vogel <sv@exept.de>
parents:
8206
diff
changeset
|
539 |
lower and upper substitution page for UCS-16" |
8206 | 540 |
(anInteger >= 16rD800) ifTrue:[ |
9153 | 541 |
(anInteger <= 16rDFFF) ifTrue:[ |
542 |
^ false. |
|
543 |
]. |
|
544 |
(anInteger == 16rFFFE) ifTrue:[ |
|
545 |
^ false. |
|
546 |
]. |
|
547 |
(anInteger == 16rFFFF) ifTrue:[ |
|
548 |
^ false. |
|
549 |
]. |
|
8206 | 550 |
]. |
551 |
^ true |
|
552 |
! |
|
553 |
||
4337
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
554 |
separators |
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
555 |
"added for squeak compatibility: return a collection of separator chars" |
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
556 |
|
9153 | 557 |
^ Array |
558 |
with:Character space |
|
559 |
with:Character return |
|
560 |
"/ with:Character cr |
|
561 |
with:Character tab |
|
562 |
with:Character lf |
|
563 |
with:Character ff |
|
564 |
||
4337
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
565 |
" |
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
566 |
Character separators |
07fad5b7af9b
added #allCharacters & #separators for Squeak compatibility
Claus Gittinger <cg@exept.de>
parents:
4037
diff
changeset
|
567 |
" |
3 | 568 |
! ! |
569 |
||
7261 | 570 |
!Character methodsFor:'Compatibility-Dolphin'! |
6324 | 571 |
|
7351
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
572 |
isAlphaNumeric |
11956 | 573 |
"Compatibility method - do not use in new code. |
574 |
Return true, if I am a letter or a digit |
|
7351
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
575 |
Please use isLetterOrDigit for compatibility reasons (which is ANSI)." |
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
576 |
|
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
577 |
^ self isLetterOrDigit |
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
578 |
! |
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
579 |
|
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
580 |
isAlphabetic |
11956 | 581 |
"Compatibility method - do not use in new code. |
582 |
Return true, if I am a letter. |
|
7351
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
583 |
Please use isLetter for compatibility reasons (which is ANSI)." |
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
584 |
|
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
585 |
^ self isLetter |
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
586 |
! |
1f805a32d551
comments in isAlphaNumeric and isAlphabetic
Claus Gittinger <cg@exept.de>
parents:
7300
diff
changeset
|
587 |
|
6324 | 588 |
isControl |
11956 | 589 |
"Compatibility method - do not use in new code. |
590 |
Return true if I am a control character (i.e. ascii value < 32)" |
|
7353 | 591 |
|
592 |
^ self isControlCharacter |
|
6324 | 593 |
! |
594 |
||
595 |
isHexDigit |
|
7354 | 596 |
"return true if I am a valid hexadecimal digit" |
597 |
||
6324 | 598 |
^ '0123456789abcdefABCDEF' includes:self |
7354 | 599 |
|
600 |
" |
|
601 |
$a isHexDigit |
|
602 |
" |
|
6324 | 603 |
! |
604 |
||
605 |
isPunctuation |
|
11956 | 606 |
"Compatibility method - do not use in new code. |
607 |
The code below is not unicode aware" |
|
7897 | 608 |
|
6327 | 609 |
^ (asciivalue between:16r21 and:16r40) |
610 |
or:[ (asciivalue between:16r5B and:16r60) |
|
611 |
or:[ (asciivalue between:123 and:126) |
|
612 |
or:[ (asciivalue between:161 and:191) |
|
613 |
or:[ (asciivalue == 215 ) |
|
614 |
or:[ (asciivalue == 247 ) ]]]]] |
|
6324 | 615 |
! ! |
616 |
||
1 | 617 |
!Character methodsFor:'accessing'! |
618 |
||
8097 | 619 |
codePoint |
620 |
"return the codePoint of myself. |
|
9153 | 621 |
Traditionally, this was named 'asciiValue'; |
8097 | 622 |
however, characters are not limited to 8bit characters." |
623 |
||
624 |
^ asciivalue |
|
625 |
! |
|
626 |
||
1 | 627 |
instVarAt:index put:anObject |
54 | 628 |
"catch instvar access - asciivalue may not be changed" |
1 | 629 |
|
630 |
self error:'Characters may not be modified' |
|
631 |
! ! |
|
632 |
||
699 | 633 |
!Character methodsFor:'arithmetic'! |
1 | 634 |
|
635 |
+ aMagnitude |
|
9153 | 636 |
"Return the Character that is <aMagnitude> higher than the receiver. |
1 | 637 |
Wrap if the resulting value is not a legal Character value. (JS)" |
638 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
639 |
^ Character codePoint:((asciivalue + aMagnitude asInteger) \\ 16r3FFFFFFF) |
1491
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
640 |
|
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
641 |
" |
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
642 |
$A + 5 |
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
643 |
" |
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
644 |
|
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
645 |
"Modified: 27.6.1996 / 12:34:51 / cg" |
1 | 646 |
! |
647 |
||
648 |
- aMagnitude |
|
9153 | 649 |
"Return the Character that is <aMagnitude> lower than the receiver. |
68 | 650 |
Wrap if the resulting value is not a legal Character value. (JS) |
9153 | 651 |
claus: |
652 |
modified to return the difference as integer, if the argument |
|
653 |
is another character. If the argument is a number, a character is |
|
654 |
returned." |
|
1 | 655 |
|
68 | 656 |
aMagnitude isCharacter ifTrue:[ |
9153 | 657 |
^ asciivalue - aMagnitude asInteger |
68 | 658 |
]. |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
659 |
^ Character codePoint:((asciivalue - aMagnitude asInteger) \\ 16r3FFFFFFF) |
68 | 660 |
|
661 |
" |
|
9153 | 662 |
$z - $a |
68 | 663 |
$d - 3 |
664 |
" |
|
1491
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
665 |
|
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
666 |
"Modified: 27.6.1996 / 12:35:34 / cg" |
1 | 667 |
! |
668 |
||
669 |
// aMagnitude |
|
9153 | 670 |
"Return the Character who's value is the receiver divided by <aMagnitude>. |
1 | 671 |
Wrap if the resulting value is not a legal Character value. (JS)" |
672 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
673 |
^ Character codePoint:(asciivalue // aMagnitude asInteger \\ 16r3FFFFFFF) |
1 | 674 |
! |
675 |
||
676 |
\\ aMagnitude |
|
9153 | 677 |
"Return the Character who's value is the receiver modulo <aMagnitude>. |
1 | 678 |
Wrap if the resulting value is not a legal Character value. (JS)" |
679 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
680 |
^ Character codePoint:(asciivalue \\ aMagnitude asInteger \\ 16r3FFFFFFF) |
1 | 681 |
! ! |
682 |
||
699 | 683 |
|
684 |
!Character methodsFor:'comparing'! |
|
685 |
||
8143 | 686 |
< aMagnitude |
7799 | 687 |
"return true, if the arguments asciiValue is greater than the receiver's" |
699 | 688 |
|
8143 | 689 |
^ (asciivalue < aMagnitude asInteger) |
699 | 690 |
! |
691 |
||
8143 | 692 |
<= aMagnitude |
7799 | 693 |
"return true, if the arguments asciiValue is greater or equal to the receiver's" |
699 | 694 |
|
8143 | 695 |
^ (asciivalue <= aMagnitude asInteger) |
699 | 696 |
! |
697 |
||
698 |
= aCharacter |
|
699 |
"return true, if the argument, aCharacter is the same character |
|
8143 | 700 |
Redefined to take care of character sizes > 8bit." |
699 | 701 |
|
702 |
self == aCharacter ifTrue:[^ true]. |
|
703 |
aCharacter isCharacter ifFalse:[^ false]. |
|
8143 | 704 |
^ asciivalue = aCharacter codePoint |
705 |
||
706 |
" |
|
9153 | 707 |
$A = 65 |
708 |
$A = 43 |
|
8143 | 709 |
" |
699 | 710 |
! |
711 |
||
8143 | 712 |
> aMagnitude |
7799 | 713 |
"return true, if the arguments asciiValue is less than the receiver's" |
699 | 714 |
|
8143 | 715 |
^ (asciivalue > aMagnitude asInteger) |
699 | 716 |
! |
717 |
||
8143 | 718 |
>= aMagnitude |
7799 | 719 |
"return true, if the arguments asciiValue is less or equal to the receiver's" |
699 | 720 |
|
8143 | 721 |
^ (asciivalue >= aMagnitude asInteger) |
699 | 722 |
! |
723 |
||
5540 | 724 |
hash |
725 |
"return an integer useful for hashing" |
|
726 |
||
727 |
^ asciivalue |
|
728 |
! |
|
729 |
||
699 | 730 |
identityHash |
731 |
"return an integer useful for hashing on identity" |
|
732 |
||
9153 | 733 |
%{ |
8100 | 734 |
INT __codePoint; |
735 |
||
736 |
__codePoint = __smallIntegerVal(__INST(asciivalue)); |
|
737 |
||
738 |
if (__codePoint <= MAX_IMMEDIATE_CHARACTER) { |
|
9153 | 739 |
RETURN ( __mkSmallInteger(__codePoint + 4096) ); |
8100 | 740 |
} |
741 |
%}. |
|
742 |
||
699 | 743 |
^ super identityHash |
8100 | 744 |
|
745 |
" |
|
746 |
$a identityHash. |
|
747 |
(Character value:1234) identityHash |
|
748 |
" |
|
699 | 749 |
! |
750 |
||
751 |
sameAs:aCharacter |
|
752 |
"return true, if the argument, aCharacter is the same character, |
|
753 |
ignoring case differences." |
|
754 |
||
755 |
self == aCharacter ifTrue:[^ true]. |
|
756 |
^ self asLowercase = aCharacter asLowercase |
|
757 |
! |
|
758 |
||
759 |
~= aCharacter |
|
760 |
"return true, if the argument, aCharacter is not the same character |
|
8143 | 761 |
Redefined to take care of character sizes > 8bit." |
699 | 762 |
|
763 |
self == aCharacter ifTrue:[^ false]. |
|
764 |
aCharacter isCharacter ifFalse:[^ true]. |
|
8097 | 765 |
^ (asciivalue ~~ aCharacter codePoint) |
699 | 766 |
! ! |
767 |
||
768 |
!Character methodsFor:'converting'! |
|
769 |
||
770 |
asCharacter |
|
771 |
"usually sent to integers, but redefined here to allow integers |
|
772 |
and characters to be used commonly without a need for a test." |
|
773 |
||
774 |
^ self |
|
775 |
||
776 |
" |
|
9153 | 777 |
32 asCharacter |
699 | 778 |
" |
779 |
! |
|
780 |
||
781 |
asInteger |
|
8143 | 782 |
"the same as #codePoint. |
783 |
Use #asInteger, if you need protocol compatibility with Numbers etc.. |
|
784 |
Use #codePoint in any other case for better stc optimization" |
|
699 | 785 |
|
786 |
^ asciivalue |
|
787 |
! |
|
788 |
||
789 |
asLowercase |
|
8010 | 790 |
"return a character with same letter as the receiver, but in lowercase. |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
791 |
Returns the receiver if it is already lowercase or if there is no lowercase equivalent. |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
792 |
CAVEAT: |
9153 | 793 |
for now, this method is only correct for unicode characters up to u+1d6ff (Unicode3.1). |
794 |
(which is more than mozilla does, btw. ;-)" |
|
7989
7907420b2fab
asUppercase / asLowercase for U0100..U04FF
Claus Gittinger <cg@exept.de>
parents:
7988
diff
changeset
|
795 |
|
8010 | 796 |
%{ |
9153 | 797 |
static int |
8010 | 798 |
__mapping[] = { |
9153 | 799 |
/* From To Every Diff */ |
8010 | 800 |
0x0041, ((0x19 << 8) | 0x01), 0x0020 , |
801 |
0x00c0, ((0x16 << 8) | 0x01), 0x0020 , |
|
802 |
0x00d8, ((0x06 << 8) | 0x01), 0x0020 , |
|
803 |
0x0100, ((0x2e << 8) | 0x02), 0x0001 , |
|
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
804 |
0x0130, ((0x00 << 8) | 0x00), -199 , |
8010 | 805 |
0x0132, ((0x04 << 8) | 0x02), 0x0001 , |
806 |
0x0139, ((0x0e << 8) | 0x02), 0x0001 , |
|
807 |
0x014a, ((0x2c << 8) | 0x02), 0x0001 , |
|
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
808 |
0x0178, ((0x00 << 8) | 0x00), -121 , |
8010 | 809 |
0x0179, ((0x04 << 8) | 0x02), 0x0001 , |
810 |
0x0181, ((0x00 << 8) | 0x00), 0x00d2 , |
|
811 |
0x0182, ((0x02 << 8) | 0x02), 0x0001 , |
|
812 |
0x0186, ((0x00 << 8) | 0x00), 0x00ce , |
|
813 |
0x0187, ((0x00 << 8) | 0x00), 0x0001 , |
|
814 |
0x0189, ((0x01 << 8) | 0x01), 0x00cd , |
|
815 |
0x018b, ((0x00 << 8) | 0x00), 0x0001 , |
|
816 |
0x018e, ((0x00 << 8) | 0x00), 0x004f , |
|
817 |
0x018f, ((0x00 << 8) | 0x00), 0x00ca , |
|
818 |
0x0190, ((0x00 << 8) | 0x00), 0x00cb , |
|
819 |
0x0191, ((0x00 << 8) | 0x00), 0x0001 , |
|
820 |
0x0193, ((0x00 << 8) | 0x00), 0x00cd , |
|
821 |
0x0194, ((0x00 << 8) | 0x00), 0x00cf , |
|
822 |
0x0196, ((0x00 << 8) | 0x00), 0x00d3 , |
|
823 |
0x0197, ((0x00 << 8) | 0x00), 0x00d1 , |
|
824 |
0x0198, ((0x00 << 8) | 0x00), 0x0001 , |
|
825 |
0x019c, ((0x00 << 8) | 0x00), 0x00d3 , |
|
826 |
0x019d, ((0x00 << 8) | 0x00), 0x00d5 , |
|
827 |
0x019f, ((0x00 << 8) | 0x00), 0x00d6 , |
|
828 |
0x01a0, ((0x04 << 8) | 0x02), 0x0001 , |
|
829 |
0x01a6, ((0x00 << 8) | 0x00), 0x00da , |
|
830 |
0x01a7, ((0x00 << 8) | 0x00), 0x0001 , |
|
831 |
0x01a9, ((0x00 << 8) | 0x00), 0x00da , |
|
832 |
0x01ac, ((0x00 << 8) | 0x00), 0x0001 , |
|
833 |
0x01ae, ((0x00 << 8) | 0x00), 0x00da , |
|
834 |
0x01af, ((0x00 << 8) | 0x00), 0x0001 , |
|
835 |
0x01b1, ((0x01 << 8) | 0x01), 0x00d9 , |
|
836 |
0x01b3, ((0x02 << 8) | 0x02), 0x0001 , |
|
837 |
0x01b7, ((0x00 << 8) | 0x00), 0x00db , |
|
838 |
0x01b8, ((0x04 << 8) | 0x04), 0x0001 , |
|
839 |
0x01c4, ((0x00 << 8) | 0x00), 0x0002 , |
|
840 |
0x01c5, ((0x00 << 8) | 0x00), 0x0001 , |
|
841 |
0x01c7, ((0x00 << 8) | 0x00), 0x0002 , |
|
842 |
0x01c8, ((0x00 << 8) | 0x00), 0x0001 , |
|
843 |
0x01ca, ((0x00 << 8) | 0x00), 0x0002 , |
|
844 |
0x01cb, ((0x10 << 8) | 0x02), 0x0001 , |
|
845 |
0x01de, ((0x10 << 8) | 0x02), 0x0001 , |
|
846 |
0x01f1, ((0x00 << 8) | 0x00), 0x0002 , |
|
847 |
0x01f2, ((0x02 << 8) | 0x02), 0x0001 , |
|
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
848 |
0x01f6, ((0x00 << 8) | 0x00), -97 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
849 |
0x01f7, ((0x00 << 8) | 0x00), -56 , |
8010 | 850 |
0x01f8, ((0x26 << 8) | 0x02), 0x0001 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
851 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
852 |
0x0220, ((0x00 << 8) | 0x00), -130 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
853 |
#endif |
8010 | 854 |
0x0222, ((0x10 << 8) | 0x02), 0x0001 , |
855 |
0x0386, ((0x00 << 8) | 0x00), 0x0026 , |
|
856 |
0x0388, ((0x02 << 8) | 0x01), 0x0025 , |
|
857 |
0x038c, ((0x00 << 8) | 0x00), 0x0040 , |
|
858 |
0x038e, ((0x01 << 8) | 0x01), 0x003f , |
|
859 |
0x0391, ((0x10 << 8) | 0x01), 0x0020 , |
|
860 |
0x03a3, ((0x08 << 8) | 0x01), 0x0020 , |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
861 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
862 |
0x03d8, ((0x00 << 8) | 0x00), 1 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
863 |
#endif |
8010 | 864 |
0x03da, ((0x14 << 8) | 0x02), 0x0001 , |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
865 |
0x03f4, ((0x00 << 8) | 0x00), -60 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
866 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
867 |
0x03f7, ((0x03 << 8) | 0x03), 1 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
868 |
0x03f9, ((0x00 << 8) | 0x00), -7 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
869 |
#endif |
8010 | 870 |
0x0400, ((0x0f << 8) | 0x01), 0x0050 , |
871 |
0x0410, ((0x1f << 8) | 0x01), 0x0020 , |
|
872 |
0x0460, ((0x20 << 8) | 0x02), 0x0001 , |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
873 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
874 |
0x048a, ((0x00 << 8) | 0x00), 1 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
875 |
#endif |
8010 | 876 |
0x048c, ((0x32 << 8) | 0x02), 0x0001 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
877 |
#ifdef UNICODE_3_2 |
8010 | 878 |
0x04c1, ((0x02 << 8) | 0x02), 0x0001 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
879 |
#else |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
880 |
0x04c1, ((0x04 << 8) | 0x02), 0x0001 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
881 |
#endif |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
882 |
#ifdef UNICODE_3_2 |
8010 | 883 |
0x04c7, ((0x04 << 8) | 0x04), 0x0001 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
884 |
#else |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
885 |
0x04c7, ((0x04 << 8) | 0x02), 0x0001 , |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
886 |
0x04cd, ((0x00 << 8) | 0x00), 0x0001 , |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
887 |
#endif |
8010 | 888 |
0x04d0, ((0x24 << 8) | 0x02), 0x0001 , |
889 |
0x04f8, ((0x00 << 8) | 0x00), 0x0001 , |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
890 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
891 |
0x0500, ((0x0E << 8) | 0x02), 1 , |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
892 |
#endif |
8010 | 893 |
0x0531, ((0x25 << 8) | 0x01), 0x0030 , |
894 |
0x1e00, ((0x94 << 8) | 0x02), 0x0001 , |
|
895 |
0x1ea0, ((0x58 << 8) | 0x02), 0x0001 , |
|
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
896 |
0x1f08, ((0x07 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
897 |
0x1f18, ((0x05 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
898 |
0x1f28, ((0x07 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
899 |
0x1f38, ((0x07 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
900 |
0x1f48, ((0x05 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
901 |
0x1f59, ((0x06 << 8) | 0x02), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
902 |
0x1f68, ((0x07 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
903 |
0x1f88, ((0x07 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
904 |
0x1f98, ((0x07 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
905 |
0x1fa8, ((0x07 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
906 |
0x1fb8, ((0x01 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
907 |
0x1fba, ((0x01 << 8) | 0x01), -74 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
908 |
0x1fbc, ((0x00 << 8) | 0x00), -9 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
909 |
0x1fc8, ((0x03 << 8) | 0x01), -86 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
910 |
0x1fcc, ((0x00 << 8) | 0x00), -9 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
911 |
0x1fd8, ((0x01 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
912 |
0x1fda, ((0x01 << 8) | 0x01), -100 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
913 |
0x1fe8, ((0x01 << 8) | 0x01), -8 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
914 |
0x1fea, ((0x01 << 8) | 0x01), -112 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
915 |
0x1fec, ((0x00 << 8) | 0x00), -7 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
916 |
0x1ff8, ((0x01 << 8) | 0x01), -128 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
917 |
0x1ffa, ((0x01 << 8) | 0x01), -126 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
918 |
0x1ffc, ((0x00 << 8) | 0x00), -9 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
919 |
0x2126, ((0x00 << 8) | 0x00), -7517 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
920 |
0x212a, ((0x00 << 8) | 0x00), -8383 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
921 |
0x212b, ((0x00 << 8) | 0x00), -8262 , |
8010 | 922 |
0x2160, ((0x0f << 8) | 0x01), 0x0010 , |
923 |
0x24b6, ((0x19 << 8) | 0x01), 0x001a , |
|
9153 | 924 |
0xff21, ((0x19 << 8) | 0x01), 0x0020 , |
925 |
0x10400, ((0x27 << 8) | 0x01), 0x0028 |
|
8010 | 926 |
}; |
1491
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
927 |
|
8010 | 928 |
REGISTER unsigned __codePoint; |
8308 | 929 |
REGISTER int * __p; |
8010 | 930 |
|
931 |
__codePoint = __intVal(__INST(asciivalue)); |
|
8106
ee222c1314e6
cannot make pointer arith with a void *
Claus Gittinger <cg@exept.de>
parents:
8100
diff
changeset
|
932 |
for (__p = __mapping; (char *)__p < ((char *)__mapping) + sizeof(__mapping); __p += 3) { |
9153 | 933 |
unsigned rangeStart, rangeSize, rangeEnd, mod; |
934 |
||
935 |
rangeStart = (unsigned)__p[0]; |
|
936 |
if (__codePoint < rangeStart) break; |
|
937 |
||
938 |
rangeSize = ((unsigned)__p[1]) >> 8; |
|
939 |
rangeEnd = rangeStart + rangeSize; |
|
940 |
if (__codePoint <= rangeEnd) { |
|
941 |
mod = __p[1] & 0xFF; |
|
942 |
if ((mod == 0) || (((__codePoint - rangeStart) % mod) == 0)) { |
|
943 |
OBJ newChar; |
|
944 |
unsigned newCodePoint; |
|
945 |
||
946 |
newCodePoint = __codePoint + __p[2]; |
|
947 |
if (newCodePoint <= MAX_IMMEDIATE_CHARACTER) { |
|
948 |
RETURN (__MKCHARACTER(newCodePoint)) ; |
|
949 |
} |
|
950 |
newChar = __MKUCHARACTER(newCodePoint) ; |
|
951 |
if (newChar == nil) goto allocationError; |
|
952 |
RETURN (newChar) ; |
|
953 |
} |
|
954 |
} |
|
8010 | 955 |
} |
956 |
RETURN (self); |
|
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
957 |
allocationError: ; |
8010 | 958 |
%}. |
959 |
^ ObjectMemory allocationFailureSignal raise. |
|
1491
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
960 |
|
a42ae3fbb756
fixed asLowercase / asUppercase for national characters
Claus Gittinger <cg@exept.de>
parents:
1295
diff
changeset
|
961 |
" |
9153 | 962 |
$A asLowercase |
963 |
$a asLowercase |
|
964 |
(Character value:16r01F5) asUppercase asLowercase |
|
965 |
(Character value:16r0205) asUppercase asLowercase |
|
966 |
(Character value:16r03B1) asUppercase asLowercase |
|
967 |
(Character value:16r1E00) asLowercase |
|
968 |
" |
|
699 | 969 |
! |
970 |
||
971 |
asString |
|
972 |
"return a string of len 1 with myself as contents" |
|
973 |
||
974 |
%{ /* NOCONTEXT */ |
|
975 |
char buffer[2]; |
|
976 |
OBJ s; |
|
995
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
977 |
unsigned val; |
699 | 978 |
|
995
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
979 |
val = __intVal(_characterVal(self)); |
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
980 |
if (val <= 0xFF) { |
9153 | 981 |
buffer[0] = (char) val; |
982 |
buffer[1] = '\0'; |
|
983 |
s = __MKSTRING_L(buffer, 1); |
|
984 |
if (s != nil) { |
|
985 |
RETURN (s); |
|
986 |
} |
|
699 | 987 |
} |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
988 |
if (val <= 0xFFFF) { |
9153 | 989 |
s = __MKEMPTYU16STRING(1); |
990 |
if (s != nil) { |
|
991 |
__Unicode16StringInstPtr(s)->s_element[0] = val; |
|
992 |
RETURN (s); |
|
993 |
} |
|
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
994 |
} |
699 | 995 |
%}. |
7951 | 996 |
asciivalue > 16rFF ifTrue:[ |
9153 | 997 |
asciivalue > 16rFFFF ifTrue:[ |
998 |
^ (Unicode32String new:1) at:1 put:self; yourself |
|
999 |
]. |
|
1000 |
^ (Unicode16String new:1) at:1 put:self; yourself |
|
995
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
1001 |
]. |
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
1002 |
|
5407 | 1003 |
^ (String new:1) at:1 put:self; yourself. |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1004 |
|
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1005 |
" |
9153 | 1006 |
(Character value:16rB5) asString |
1007 |
(Character value:16r1B5) asString |
|
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1008 |
" |
699 | 1009 |
! |
1010 |
||
1011 |
asSymbol |
|
9229 | 1012 |
"Return a unique symbol with the name taken from the receivers characters. |
1013 |
Here, a single character symbol is returned." |
|
699 | 1014 |
|
1015 |
^ Symbol internCharacter:self |
|
1016 |
! |
|
1017 |
||
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1018 |
asTitlecase |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1019 |
"return a character with same letter as the receiver, but in titlecase. |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1020 |
Returns the receiver if it is already titlecase or if there is no titlecase equivalent." |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1021 |
|
8026 | 1022 |
" |
9153 | 1023 |
For example, in Unicode, character U+01F3 is LATIN SMALL LETTER DZ. |
1024 |
(Let us write this compound character using ASCII as 'dz'.) |
|
1025 |
This character uppercases to character U+01F1, LATIN CAPITAL LETTER DZ. |
|
1026 |
(Which is basically 'DZ'.) |
|
1027 |
But it titlecases to to character U+01F2, LATIN CAPITAL LETTER D WITH SMALL LETTER Z. |
|
8026 | 1028 |
(Which we can write 'Dz'.) |
1029 |
||
1030 |
character uppercase titlecase |
|
1031 |
--------- --------- --------- |
|
1032 |
dz DZ Dz |
|
1033 |
" |
|
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1034 |
|ch| |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1035 |
|
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1036 |
%{ |
8308 | 1037 |
static unsigned short |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1038 |
__mapping[] = { |
9153 | 1039 |
0x01F1, 0x01F2, |
1040 |
0x01F3, 0x01F2, |
|
1041 |
0x01C4, 0x01C5, |
|
1042 |
0x01C6, 0x01C5, |
|
1043 |
0x01C7, 0x01C8, |
|
1044 |
0x01C9, 0x01C8, |
|
1045 |
0x01CA, 0x01CB, |
|
1046 |
0x01CC, 0x01CB, |
|
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1047 |
}; |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1048 |
|
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1049 |
REGISTER unsigned __codePoint; |
8885 | 1050 |
REGISTER unsigned short *__p; |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1051 |
|
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1052 |
__codePoint = __intVal(__INST(asciivalue)); |
8106
ee222c1314e6
cannot make pointer arith with a void *
Claus Gittinger <cg@exept.de>
parents:
8100
diff
changeset
|
1053 |
for (__p = __mapping; (char *)__p < ((char *)__mapping) + sizeof(__mapping); __p += 2) { |
9153 | 1054 |
if ((__codePoint == __p[0]) || (__codePoint == __p[1])) { |
1055 |
short newCodePoint; |
|
1056 |
OBJ newChar; |
|
1057 |
||
1058 |
newCodePoint = __p[1]; |
|
1059 |
if (newCodePoint == __codePoint) { |
|
1060 |
RETURN (self); |
|
1061 |
} |
|
1062 |
if (newCodePoint <= MAX_IMMEDIATE_CHARACTER) { |
|
1063 |
RETURN (__MKCHARACTER(newCodePoint)) ; |
|
1064 |
} |
|
1065 |
newChar = __MKUCHARACTER(newCodePoint) ; |
|
1066 |
if (newChar == nil) goto getOutOfHere; |
|
1067 |
RETURN (newChar) ; |
|
1068 |
} |
|
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1069 |
} |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1070 |
ch = self; |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1071 |
getOutOfHere: ; |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1072 |
%}. |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1073 |
ch notNil ifTrue:[ |
9153 | 1074 |
^ ch asUppercase. |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1075 |
]. |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1076 |
|
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1077 |
^ ObjectMemory allocationFailureSignal raise. |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1078 |
|
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1079 |
" |
9153 | 1080 |
$A asTitlecase |
1081 |
$a asTitlecase |
|
1082 |
(Character value:16r01F1) asTitlecase |
|
1083 |
" |
|
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1084 |
! |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1085 |
|
6029 | 1086 |
asUnicodeString |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1087 |
"return a unicode string of len 1 with myself as contents. |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1088 |
This will vanish, as we now (rel5.2.x) use Unicode as default." |
6029 | 1089 |
|
7951 | 1090 |
asciivalue > 16rFFFF ifTrue:[ |
9153 | 1091 |
^ (Unicode32String new:1) at:1 put:self; yourself. |
7951 | 1092 |
]. |
1093 |
^ (Unicode16String new:1) at:1 put:self; yourself. |
|
6029 | 1094 |
! |
1095 |
||
699 | 1096 |
asUppercase |
8010 | 1097 |
"return a character with same letter as the receiver, but in uppercase. |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1098 |
Returns the receiver if it is already uppercase or if there is no uppercase equivalent. |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1099 |
CAVEAT: |
9153 | 1100 |
for now, this method is only correct for unicode characters up to u+1d6ff (Unicode3.1). |
1101 |
(which is more than mozilla does, btw. ;-)" |
|
7990
2f78c1d609c7
asUppercase / asLowercase for UFF00..UFFFF
Claus Gittinger <cg@exept.de>
parents:
7989
diff
changeset
|
1102 |
|
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1103 |
%{ |
8308 | 1104 |
static int |
8010 | 1105 |
__mapping[] = { |
9153 | 1106 |
/* From To Every Diff */ |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1107 |
0x0061, ((0x19 << 8) | 0x01), -32 , |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1108 |
0x00b5, ((0x00 << 8) | 0x3b), 0x02e7 , |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1109 |
0x00e0, ((0x16 << 8) | 0x01), -32 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1110 |
0x00f8, ((0x06 << 8) | 0x01), -32 , |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1111 |
0x00ff, ((0x00 << 8) | 0x01), 0x0079 , |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1112 |
0x0101, ((0x2e << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1113 |
0x0131, ((0x00 << 8) | 0x02), -232 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1114 |
0x0133, ((0x04 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1115 |
0x013a, ((0x0e << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1116 |
0x014b, ((0x2c << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1117 |
0x017a, ((0x04 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1118 |
0x017f, ((0x00 << 8) | 0x01), -300 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1119 |
0x0183, ((0x02 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1120 |
0x0188, ((0x04 << 8) | 0x04), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1121 |
0x0192, ((0x00 << 8) | 0x06), -1 , |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1122 |
0x0195, ((0x00 << 8) | 0x03), 0x0061 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1123 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1124 |
0x0199, ((0x04 << 8) | 0x08), -1 , |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1125 |
0x019e, ((0x00 << 8) | 0x00), 130 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1126 |
#endif |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1127 |
0x0199, ((0x08 << 8) | 0x08), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1128 |
0x01a3, ((0x02 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1129 |
0x01a8, ((0x05 << 8) | 0x05), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1130 |
0x01b0, ((0x04 << 8) | 0x04), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1131 |
0x01b6, ((0x03 << 8) | 0x03), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1132 |
0x01bd, ((0x00 << 8) | 0x04), -1 , |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1133 |
0x01bf, ((0x00 << 8) | 0x02), 0x0038 , |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1134 |
0x01c5, ((0x00 << 8) | 0x06), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1135 |
0x01c6, ((0x00 << 8) | 0x01), -2 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1136 |
0x01c8, ((0x00 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1137 |
0x01c9, ((0x00 << 8) | 0x01), -2 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1138 |
0x01cb, ((0x00 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1139 |
0x01cc, ((0x00 << 8) | 0x01), -2 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1140 |
0x01ce, ((0x0e << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1141 |
0x01dd, ((0x00 << 8) | 0x01), -79 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1142 |
0x01df, ((0x10 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1143 |
0x01f2, ((0x00 << 8) | 0x03), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1144 |
0x01f3, ((0x00 << 8) | 0x01), -2 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1145 |
0x01f5, ((0x04 << 8) | 0x04), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1146 |
0x01fb, ((0x24 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1147 |
0x0223, ((0x10 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1148 |
0x0253, ((0x00 << 8) | 0x20), -210 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1149 |
0x0254, ((0x00 << 8) | 0x01), -206 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1150 |
0x0256, ((0x01 << 8) | 0x01), -205 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1151 |
0x0259, ((0x00 << 8) | 0x02), -202 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1152 |
0x025b, ((0x00 << 8) | 0x02), -203 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1153 |
0x0260, ((0x00 << 8) | 0x05), -205 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1154 |
0x0263, ((0x00 << 8) | 0x03), -207 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1155 |
0x0268, ((0x00 << 8) | 0x05), -209 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1156 |
0x0269, ((0x06 << 8) | 0x06), -211 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1157 |
0x0272, ((0x00 << 8) | 0x03), -213 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1158 |
0x0275, ((0x00 << 8) | 0x03), -214 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1159 |
0x0280, ((0x03 << 8) | 0x03), -218 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1160 |
0x0288, ((0x00 << 8) | 0x05), -218 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1161 |
0x028a, ((0x01 << 8) | 0x01), -217 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1162 |
0x0292, ((0x00 << 8) | 0x07), -219 , |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1163 |
0x0345, ((0x00 << 8) | 0xb3), 0x0054 , |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1164 |
0x03ac, ((0x00 << 8) | 0x67), -38 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1165 |
0x03ad, ((0x02 << 8) | 0x01), -37 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1166 |
0x03b1, ((0x10 << 8) | 0x01), -32 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1167 |
0x03c2, ((0x00 << 8) | 0x01), -31 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1168 |
0x03c3, ((0x08 << 8) | 0x01), -32 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1169 |
0x03cc, ((0x00 << 8) | 0x01), -64 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1170 |
0x03cd, ((0x01 << 8) | 0x01), -63 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1171 |
0x03d0, ((0x00 << 8) | 0x02), -62 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1172 |
0x03d1, ((0x00 << 8) | 0x01), -57 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1173 |
0x03d5, ((0x00 << 8) | 0x04), -47 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1174 |
0x03d6, ((0x00 << 8) | 0x01), -54 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1175 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1176 |
0x03d9, ((0x00 << 8) | 0x00), -1 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1177 |
#endif |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1178 |
0x03db, ((0x14 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1179 |
0x03f0, ((0x00 << 8) | 0x01), -86 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1180 |
0x03f1, ((0x00 << 8) | 0x01), -80 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1181 |
#ifdef UNICODE_3_2 |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1182 |
0x03f2, ((0x00 << 8) | 0x01), -79 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1183 |
#else |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1184 |
0x03f2, ((0x00 << 8) | 0x00), 7 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1185 |
#endif |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1186 |
0x03f5, ((0x00 << 8) | 0x00), -96 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1187 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1188 |
0x03f8, ((0x03 << 8) | 0x03), -1 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1189 |
#endif |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1190 |
0x0430, ((0x1f << 8) | 0x01), -32 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1191 |
0x0450, ((0x0f << 8) | 0x01), -80 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1192 |
0x0461, ((0x20 << 8) | 0x02), -1 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1193 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1194 |
0x048b, ((0x00 << 8) | 0x00), -1 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1195 |
#endif |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1196 |
0x048d, ((0x32 << 8) | 0x02), -1 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1197 |
#ifdef UNICODE_3_2 |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1198 |
0x04c2, ((0x02 << 8) | 0x02), -1 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1199 |
#else |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1200 |
0x04c2, ((0x04 << 8) | 0x02), -1 , /* Unicode4.0 - not in X fonts - sigh */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1201 |
#endif |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1202 |
#ifdef UNICODE_3_2 |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1203 |
0x04c8, ((0x04 << 8) | 0x04), -1 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1204 |
#else |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1205 |
0x04c8, ((0x04 << 8) | 0x02), -1 , |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1206 |
0x04ce, ((0x00 << 8) | 0x00), -1 , |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1207 |
#endif |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1208 |
0x04d1, ((0x24 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1209 |
0x04f9, ((0x00 << 8) | 0x04), -1 , |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1210 |
#ifndef UNICODE_3_2 |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1211 |
0x0501, ((0x0E << 8) | 0x02), -1 , |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1212 |
#endif |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1213 |
0x0561, ((0x25 << 8) | 0x01), -48 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1214 |
0x1e01, ((0x94 << 8) | 0x02), -1 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1215 |
0x1e9b, ((0x00 << 8) | 0x06), -59 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1216 |
0x1ea1, ((0x58 << 8) | 0x02), -1 , |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1217 |
0x1f00, ((0x07 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1218 |
0x1f10, ((0x05 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1219 |
0x1f20, ((0x07 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1220 |
0x1f30, ((0x07 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1221 |
0x1f40, ((0x05 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1222 |
0x1f51, ((0x06 << 8) | 0x02), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1223 |
0x1f60, ((0x07 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1224 |
0x1f70, ((0x01 << 8) | 0x01), 0x004a , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1225 |
0x1f72, ((0x03 << 8) | 0x01), 0x0056 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1226 |
0x1f76, ((0x01 << 8) | 0x01), 0x0064 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1227 |
0x1f78, ((0x01 << 8) | 0x01), 0x0080 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1228 |
0x1f7a, ((0x01 << 8) | 0x01), 0x0070 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1229 |
0x1f7c, ((0x01 << 8) | 0x01), 0x007e , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1230 |
0x1f80, ((0x07 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1231 |
0x1f90, ((0x07 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1232 |
0x1fa0, ((0x07 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1233 |
0x1fb0, ((0x01 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1234 |
0x1fb3, ((0x00 << 8) | 0x02), 0x0009 , |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1235 |
0x1fbe, ((0x00 << 8) | 0x0b), -7205 , |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1236 |
0x1fc3, ((0x00 << 8) | 0x05), 0x0009 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1237 |
0x1fd0, ((0x01 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1238 |
0x1fe0, ((0x01 << 8) | 0x01), 0x0008 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1239 |
0x1fe5, ((0x00 << 8) | 0x04), 0x0007 , |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1240 |
0x1ff3, ((0x00 << 8) | 0x0e), 0x0009 , |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1241 |
0x2170, ((0x0f << 8) | 0x01), -16 , |
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1242 |
0x24d0, ((0x19 << 8) | 0x01), -26 , |
9153 | 1243 |
0xff41, ((0x19 << 8) | 0x01), -32 , |
1244 |
0x10428, ((0x27 << 8) | 0x01), -40 |
|
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1245 |
}; |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1246 |
|
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1247 |
REGISTER unsigned __codePoint; |
8308 | 1248 |
REGISTER int *__p; |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1249 |
|
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1250 |
__codePoint = __intVal(__INST(asciivalue)); |
8106
ee222c1314e6
cannot make pointer arith with a void *
Claus Gittinger <cg@exept.de>
parents:
8100
diff
changeset
|
1251 |
for (__p = __mapping; (char *)__p < ((char *)__mapping) + sizeof(__mapping); __p += 3) { |
9153 | 1252 |
unsigned rangeStart, rangeSize, rangeEnd, mod; |
1253 |
||
1254 |
rangeStart = (unsigned)__p[0]; |
|
1255 |
if (__codePoint < rangeStart) break; |
|
1256 |
||
1257 |
rangeSize = ((unsigned)__p[1]) >> 8; |
|
1258 |
rangeEnd = rangeStart + rangeSize; |
|
1259 |
if (__codePoint <= rangeEnd) { |
|
1260 |
mod = __p[1] & 0xFF; |
|
1261 |
if ((mod == 0) || (((__codePoint - rangeStart) % mod) == 0)) { |
|
1262 |
OBJ newChar; |
|
1263 |
unsigned newCodePoint; |
|
1264 |
||
1265 |
newCodePoint = __codePoint + __p[2]; |
|
1266 |
if (newCodePoint <= MAX_IMMEDIATE_CHARACTER) { |
|
1267 |
RETURN (__MKCHARACTER(newCodePoint)) ; |
|
1268 |
} |
|
1269 |
newChar = __MKUCHARACTER(newCodePoint) ; |
|
1270 |
if (newChar == nil) goto allocationError; |
|
1271 |
RETURN (newChar) ; |
|
1272 |
} |
|
1273 |
} |
|
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1274 |
} |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1275 |
RETURN (self); |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1276 |
allocationError: ; |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1277 |
%}. |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1278 |
^ ObjectMemory allocationFailureSignal raise. |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1279 |
|
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1280 |
" |
9153 | 1281 |
$A asLowercase |
1282 |
$a asUppercase |
|
1283 |
(Character value:16r01F5) asUppercase |
|
1284 |
(Character value:16r0205) asUppercase |
|
1285 |
(Character value:16r03B1) asUppercase |
|
1286 |
" |
|
8010 | 1287 |
! |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1288 |
|
8010 | 1289 |
digitValue |
11653 | 1290 |
"return my digitValue for any base (up to 37)" |
8010 | 1291 |
|
8143 | 1292 |
|code "{ Class: SmallInteger }" | |
1293 |
||
1294 |
code := asciivalue. |
|
1295 |
(code between:($0 codePoint) and:($9 codePoint)) ifTrue:[ |
|
11653 | 1296 |
^ code - $0 codePoint |
8010 | 1297 |
]. |
8143 | 1298 |
(code between:($a codePoint) and:($z codePoint)) ifTrue:[ |
11653 | 1299 |
^ code + (10 - $a codePoint) |
9153 | 1300 |
]. |
8143 | 1301 |
(code between:($A codePoint) and:($Z codePoint)) ifTrue:[ |
11653 | 1302 |
^ code + (10 - $A codePoint) |
9153 | 1303 |
]. |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1304 |
|
8010 | 1305 |
"remove error below for X3J20 conformance ... " |
1306 |
self error:'bad character'. |
|
1307 |
" " |
|
1308 |
^ -1 |
|
1309 |
! |
|
1310 |
||
11653 | 1311 |
digitValueRadix:base |
1312 |
"return my digitValue for base. |
|
1313 |
Return nil, if it is not a valid character for that base" |
|
1314 |
||
1315 |
|code "{ Class: SmallInteger }" | |
|
1316 |
||
1317 |
code := asciivalue. |
|
1318 |
base < 10 ifTrue:[ |
|
1319 |
(code between:($0 codePoint) and:($0 codePoint + base - 1)) ifTrue:[ |
|
1320 |
^ code - $0 codePoint |
|
1321 |
]. |
|
1322 |
^ nil. |
|
1323 |
]. |
|
1324 |
(code between:($0 codePoint) and:($9 codePoint)) ifTrue:[ |
|
1325 |
^ code - $0 codePoint |
|
1326 |
]. |
|
1327 |
base <= 10 ifTrue:[ |
|
1328 |
^ nil. |
|
1329 |
]. |
|
1330 |
(code between:($a codePoint) and:($a codePoint + base - 1 - 10)) ifTrue:[ |
|
1331 |
^ code + (10 - $a codePoint) |
|
1332 |
]. |
|
1333 |
(code between:($A codePoint) and:($A codePoint + base - 1 - 10)) ifTrue:[ |
|
1334 |
^ code + (10 - $A codePoint) |
|
1335 |
]. |
|
1336 |
^ nil |
|
1337 |
||
1338 |
" |
|
1339 |
self assert:($0 digitValueRadix:10) == 0. |
|
1340 |
self assert:($9 digitValueRadix:10) == 9. |
|
1341 |
self assert:($a digitValueRadix:10) == nil. |
|
1342 |
self assert:($a digitValueRadix:11) == 10. |
|
1343 |
self assert:($A digitValueRadix:11) == 10. |
|
1344 |
self assert:($a digitValueRadix:16) == 10. |
|
1345 |
self assert:($A digitValueRadix:16) == 10. |
|
1346 |
self assert:($f digitValueRadix:16) == 15. |
|
1347 |
self assert:($F digitValueRadix:16) == 15. |
|
1348 |
self assert:($g digitValueRadix:16) == nil. |
|
1349 |
self assert:($G digitValueRadix:16) == nil. |
|
1350 |
self assert:($g digitValueRadix:17) == 16. |
|
1351 |
self assert:($G digitValueRadix:17) == 16. |
|
1352 |
" |
|
1353 |
! |
|
1354 |
||
8010 | 1355 |
literalArrayEncoding |
1356 |
"encode myself as an array literal, from which a copy of the receiver |
|
1357 |
can be reconstructed with #decodeAsLiteralArray." |
|
1358 |
||
1359 |
^ self |
|
1360 |
||
1361 |
"Created: / 27.10.1997 / 14:40:37 / cg" |
|
1362 |
! |
|
1363 |
||
1364 |
to:aMagnitude |
|
9153 | 1365 |
"Return an Interval over the characters from the receiver to <aMagnitude>. |
8010 | 1366 |
Wrap <aMagnitude> if it is not a legal Character value. (JS)" |
1367 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1368 |
^ Interval from:self to:(aMagnitude \\ 16r3FFFFFFF) |
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1369 |
! |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1370 |
|
5847 | 1371 |
utf8Encoded |
11321 | 1372 |
"convert a character to its UTF-8 encoding. |
5847 | 1373 |
this returns a String" |
1374 |
||
1375 |
|s| |
|
1376 |
||
7897 | 1377 |
asciivalue <= 16r7F ifTrue:[ |
11321 | 1378 |
^ self asString. |
7897 | 1379 |
]. |
1380 |
||
8222
f2c454a9a038
replaced '' writeStream by String writeStream
Claus Gittinger <cg@exept.de>
parents:
8207
diff
changeset
|
1381 |
s := WriteStream on:(String new:6). |
11321 | 1382 |
s nextPutUtf8:self. |
5847 | 1383 |
^ s contents |
9153 | 1384 |
|
5847 | 1385 |
" |
11321 | 1386 |
'ä' utf8Encoded |
5847 | 1387 |
" |
699 | 1388 |
! ! |
1389 |
||
1390 |
!Character methodsFor:'copying'! |
|
1391 |
||
1392 |
copy |
|
1393 |
"return a copy of myself |
|
1394 |
reimplemented since characters are unique" |
|
1395 |
||
1396 |
^ self |
|
1397 |
! |
|
1398 |
||
10948 | 1399 |
deepCopyUsing:aDictionary postCopySelector:postCopySelector |
699 | 1400 |
"return a deep copy of myself |
4728 | 1401 |
reimplemented since characters are immutable" |
699 | 1402 |
|
1403 |
^ self |
|
1404 |
! |
|
1405 |
||
1406 |
shallowCopy |
|
1407 |
"return a shallow copy of myself |
|
4728 | 1408 |
reimplemented since characters are immutable" |
699 | 1409 |
|
1410 |
^ self |
|
1411 |
! |
|
1412 |
||
1413 |
simpleDeepCopy |
|
1414 |
"return a deep copy of myself |
|
4728 | 1415 |
reimplemented since characters are immutable" |
699 | 1416 |
|
1417 |
^ self |
|
1418 |
! ! |
|
1419 |
||
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5452
diff
changeset
|
1420 |
!Character methodsFor:'encoding'! |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5452
diff
changeset
|
1421 |
|
6508 | 1422 |
rot13 |
9153 | 1423 |
"Usenet: from `rotate alphabet 13 places'] |
6508 | 1424 |
The simple Caesar-cypher encryption that replaces each English |
9153 | 1425 |
letter with the one 13 places forward or back along the alphabet, |
6508 | 1426 |
so that 'The butler did it!!' becomes 'Gur ohgyre qvq vg!!' |
9153 | 1427 |
Most Usenet news reading and posting programs include a rot13 feature. |
6508 | 1428 |
It is used to enclose the text in a sealed wrapper that the reader must choose |
9153 | 1429 |
to open -- e.g., for posting things that might offend some readers, or spoilers. |
6508 | 1430 |
A major advantage of rot13 over rot(N) for other N is that it |
1431 |
is self-inverse, so the same code can be used for encoding and decoding." |
|
1432 |
||
11864 | 1433 |
^ self rot:13 |
6508 | 1434 |
|
1435 |
" |
|
9153 | 1436 |
$h rot13 |
1437 |
$h rot13 rot13 |
|
7715
0e69a830f5d8
use #and: - not #& you lazy bone, you
Claus Gittinger <cg@exept.de>
parents:
7689
diff
changeset
|
1438 |
'The butler did it!!' rot13 -> 'Gur ohgyre qvq vg!!' |
0e69a830f5d8
use #and: - not #& you lazy bone, you
Claus Gittinger <cg@exept.de>
parents:
7689
diff
changeset
|
1439 |
'The butler did it!!' rot13 rot13 -> 'The butler did it!!' |
6508 | 1440 |
" |
11864 | 1441 |
! |
1442 |
||
1443 |
rot:n |
|
1444 |
"Usenet: from `rotate alphabet N places'] |
|
1445 |
The simple Caesar-cypher encryption that replaces each English |
|
1446 |
letter with the one N places forward or back along the alphabet, |
|
1447 |
so that 'The butler did it!!' becomes 'Gur ohgyre qvq vg!!' by rot:13 |
|
1448 |
Most Usenet news reading and posting programs include a rot13 feature. |
|
1449 |
It is used to enclose the text in a sealed wrapper that the reader must choose |
|
1450 |
to open -- e.g., for posting things that might offend some readers, or spoilers. |
|
1451 |
A major advantage of rot13 over rot(N) for other N is that it |
|
1452 |
is self-inverse, so the same code can be used for encoding and decoding." |
|
1453 |
||
1454 |
(self isLetter) ifTrue:[ |
|
1455 |
self isLowercase ifTrue:[ |
|
1456 |
^ 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' at:(self-$a+1+n) |
|
1457 |
]. |
|
1458 |
^ 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ' at:(self-$A+1+n) |
|
1459 |
]. |
|
1460 |
^ self |
|
1461 |
||
1462 |
" |
|
1463 |
'The butler did it!!' rot:13 -> 'Gur ohgyre qvq vg!!' |
|
1464 |
('The butler did it!!' rot:13) rot:13 -> 'The butler did it!!' |
|
1465 |
" |
|
5471
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5452
diff
changeset
|
1466 |
! ! |
a57eeb01c5ab
General encoding method (#encodeOn:with:)
Stefan Vogel <sv@exept.de>
parents:
5452
diff
changeset
|
1467 |
|
10428 | 1468 |
|
8143 | 1469 |
!Character methodsFor:'obsolete'! |
1470 |
||
1471 |
asciiValue |
|
1472 |
"return the asciivalue of myself. |
|
1473 |
The name 'asciiValue' is a historic leftover: |
|
9153 | 1474 |
characters are not limited to 8bit characters. |
8143 | 1475 |
So the actual value returned is a codePoint (i.e. full potential for 31bit encoding). |
1476 |
PP has removed this method with 4.1 and providing asInteger instead. |
|
1477 |
ANSI defines #codePoint, please use this method" |
|
1478 |
||
1479 |
<resource:#obsolete> |
|
1480 |
||
1481 |
^ asciivalue |
|
1482 |
||
1483 |
"Modified: 27.6.1996 / 12:34:34 / cg" |
|
1484 |
! ! |
|
1485 |
||
699 | 1486 |
!Character methodsFor:'printing & storing'! |
1487 |
||
1488 |
displayString |
|
1489 |
"return a string used when the receiver is to be displayed |
|
1490 |
in an inspector kind-of-thing" |
|
1491 |
||
2908 | 1492 |
^ (self storeString , ' "16r' , (asciivalue printStringRadix:16) , '"') |
699 | 1493 |
! |
1494 |
||
1495 |
isLiteral |
|
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1496 |
"return true, if the receiver can be used as a literal constant in ST syntax |
699 | 1497 |
(i.e. can be used in constant arrays)" |
1498 |
||
1499 |
^ true |
|
1500 |
! |
|
1501 |
||
1502 |
||
5746
cf5e42cb72ef
do not overwrite the standard printing conventions
Claus Gittinger <cg@exept.de>
parents:
5566
diff
changeset
|
1503 |
"print myself on stdout. |
9153 | 1504 |
This method does NOT (by purpose) use the stream classes and |
5746
cf5e42cb72ef
do not overwrite the standard printing conventions
Claus Gittinger <cg@exept.de>
parents:
5566
diff
changeset
|
1505 |
will therefore work even in case of emergency (but only, if Stdout is nil)." |
699 | 1506 |
|
1507 |
%{ /* NOCONTEXT */ |
|
1508 |
||
5746
cf5e42cb72ef
do not overwrite the standard printing conventions
Claus Gittinger <cg@exept.de>
parents:
5566
diff
changeset
|
1509 |
if (@global(Stdout) == nil) { |
9153 | 1510 |
putchar(__intVal(__INST(asciivalue))); |
1511 |
RETURN(self); |
|
5746
cf5e42cb72ef
do not overwrite the standard printing conventions
Claus Gittinger <cg@exept.de>
parents:
5566
diff
changeset
|
1512 |
} |
5452
71fd110c347a
allow print, printCR during early initialization
Claus Gittinger <cg@exept.de>
parents:
5433
diff
changeset
|
1513 |
%}. |
71fd110c347a
allow print, printCR during early initialization
Claus Gittinger <cg@exept.de>
parents:
5433
diff
changeset
|
1514 |
super print |
699 | 1515 |
! |
1516 |
||
1517 |
printOn:aStream |
|
1518 |
"print myself on aStream" |
|
1519 |
||
1520 |
aStream nextPut:self |
|
1521 |
! |
|
1522 |
||
1523 |
printString |
|
1524 |
"return a string to print me" |
|
1525 |
||
1526 |
^ self asString |
|
1527 |
! |
|
1528 |
||
1529 |
storeOn:aStream |
|
1530 |
"store myself on aStream" |
|
1531 |
||
1532 |
|special| |
|
1533 |
||
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1534 |
(asciivalue between:33 and:127) ifTrue:[ |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1535 |
aStream nextPut:$$; nextPut:self |
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1536 |
] ifFalse:[ |
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1537 |
(self == Character space) ifTrue:[ |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1538 |
special := #space |
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1539 |
] ifFalse:[ |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1540 |
(self == Character cr) ifTrue:[ |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1541 |
special := #cr. |
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1542 |
] ifFalse:[ |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1543 |
(self == Character tab) ifTrue:[ |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1544 |
special := #tab. |
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1545 |
] ifFalse:[ |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1546 |
(self == Character esc) ifTrue:[ |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1547 |
special := #esc. |
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1548 |
] |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1549 |
] |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1550 |
] |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1551 |
]. |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1552 |
special notNil ifTrue:[ |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1553 |
aStream nextPutAll:'(Character '; nextPutAll:special; nextPut:$). |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1554 |
^ self |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1555 |
]. |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1556 |
aStream nextPutAll:'(Character codePoint:16r'. |
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1557 |
asciivalue printOn:aStream base:16. |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
1558 |
aStream nextPut:$) |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1559 |
]. |
995
b018368b3a94
asString to 16-bit char should return a twoByteString
Claus Gittinger <cg@exept.de>
parents:
819
diff
changeset
|
1560 |
|
3190
81ffb25d1d86
Use #printOn: instead of #printString
Stefan Vogel <sv@exept.de>
parents:
3072
diff
changeset
|
1561 |
"Modified: / 23.2.1996 / 23:27:32 / cg" |
81ffb25d1d86
Use #printOn: instead of #printString
Stefan Vogel <sv@exept.de>
parents:
3072
diff
changeset
|
1562 |
"Modified: / 20.1.1998 / 14:10:46 / stefan" |
699 | 1563 |
! ! |
1564 |
||
7257 | 1565 |
!Character methodsFor:'private-accessing'! |
699 | 1566 |
|
8100 | 1567 |
setCodePoint:anInteger |
9153 | 1568 |
"very private - set the codePoint. |
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1569 |
- use this only for newly created characters with codes > MAX_IMMEDIATE_CHARACTER. |
9153 | 1570 |
DANGER alert: |
1571 |
funny things happen, if this is applied to |
|
10936
9381620deb4d
use #codePoint: instead of #value:
Stefan Vogel <sv@exept.de>
parents:
10428
diff
changeset
|
1572 |
one of the shared characters with codePoints 0..MAX_IMMEDIATE_CHARACTER." |
699 | 1573 |
|
1574 |
asciivalue := anInteger |
|
1575 |
! ! |
|
1576 |
||
8004
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1577 |
!Character methodsFor:'queries'! |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1578 |
|
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1579 |
bitsPerCharacter |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1580 |
"return the number of bits I require for storage" |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1581 |
|
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1582 |
asciivalue <= 16rFF ifTrue:[^ 8]. |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1583 |
asciivalue <= 16rFFFF ifTrue:[^ 16]. |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1584 |
^ 32 |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1585 |
! |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1586 |
|
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1587 |
stringSpecies |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1588 |
"return the type of string that is needed to store me" |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1589 |
|
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1590 |
asciivalue <= 16rFF ifTrue:[^ String]. |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1591 |
asciivalue <= 16rFFFF ifTrue:[^ Unicode16String]. |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1592 |
^ Unicode32String |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1593 |
! ! |
a09a6a745e65
asLowercase/asUppercase and friends care for 16-bit chars
Claus Gittinger <cg@exept.de>
parents:
7997
diff
changeset
|
1594 |
|
1 | 1595 |
!Character methodsFor:'testing'! |
1596 |
||
54 | 1597 |
isCharacter |
1598 |
"return true, if the receiver is some kind of character" |
|
1599 |
||
1600 |
^ true |
|
1601 |
! |
|
1602 |
||
3667 | 1603 |
isControlCharacter |
8097 | 1604 |
"return true if I am a control character (i.e. ascii value < 32 or == 16rFF)" |
3667 | 1605 |
|
1606 |
%{ /* NOCONTEXT */ |
|
1607 |
#ifdef NON_ASCII /* i.e. EBCDIC ;-) */ |
|
8097 | 1608 |
# error not yet implemented - fails when compiled |
3667 | 1609 |
#else |
1610 |
REGISTER int val; |
|
1611 |
||
1612 |
val = __intVal(__INST(asciivalue)); |
|
8097 | 1613 |
if (val < ' ' || val == 0xFF) { |
9153 | 1614 |
RETURN ( true ); |
3667 | 1615 |
} |
1616 |
#endif |
|
5423
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1617 |
RETURN (false); |
3667 | 1618 |
%}. |
1619 |
||
1620 |
" |
|
1621 |
(Character value:1) isControlCharacter |
|
1622 |
$a isControlCharacter |
|
1623 |
" |
|
1624 |
! |
|
1625 |
||
1 | 1626 |
isDigit |
1627 |
"return true, if I am a digit (i.e. $0 .. $9)" |
|
1628 |
||
7980 | 1629 |
%{ /* NOCONTEXT */ |
6527 | 1630 |
|
1631 |
REGISTER int val; |
|
1632 |
||
1633 |
val = __intVal(__INST(asciivalue)); |
|
1634 |
if ((unsigned)(val - '0') <= ('9' - '0')) { |
|
9153 | 1635 |
RETURN ( true ); |
6527 | 1636 |
} |
1637 |
RETURN ( false ); |
|
1638 |
%}. |
|
8097 | 1639 |
^ asciivalue between:$0 codePoint and:$9 codePoint |
1 | 1640 |
! |
1641 |
||
1642 |
isDigitRadix:r |
|
1643 |
"return true, if I am a digit of a base r number" |
|
1644 |
||
9153 | 1645 |
(asciivalue < $0 codePoint) ifTrue:[^ false]. |
1 | 1646 |
(r > 10) ifTrue:[ |
9153 | 1647 |
(asciivalue <= $9 codePoint) ifTrue:[ |
1648 |
^ true |
|
1649 |
]. |
|
1650 |
((asciivalue - $a codePoint) between:0 and:(r - 11)) ifTrue:[ |
|
1651 |
^ true |
|
1652 |
]. |
|
1653 |
^ (asciivalue - $A codePoint) between:0 and:(r - 11) |
|
1 | 1654 |
]. |
8097 | 1655 |
(asciivalue - $0 codePoint) < r ifTrue:[^ true]. |
1 | 1656 |
^ false |
1657 |
! |
|
1658 |
||
699 | 1659 |
isEndOfLineCharacter |
1660 |
"return true if I am a line delimitting character" |
|
1 | 1661 |
|
1662 |
%{ /* NOCONTEXT */ |
|
1663 |
||
1664 |
REGISTER int val; |
|
1665 |
||
1133 | 1666 |
val = __intVal(__INST(asciivalue)); |
699 | 1667 |
if ((val == '\n') |
1668 |
|| (val == '\r') |
|
1669 |
|| (val == '\f')) { |
|
9153 | 1670 |
RETURN ( true ); |
54 | 1671 |
} |
5423
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1672 |
RETURN (false); |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1673 |
%}. |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1674 |
^ asciivalue == 16r0A |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1675 |
or:[asciivalue == 16r0D |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1676 |
or:[asciivalue == 16r0C]] |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1677 |
|
1 | 1678 |
! |
1679 |
||
5473
c48d8c45c740
isImmediate returns true for shared characters
Claus Gittinger <cg@exept.de>
parents:
5471
diff
changeset
|
1680 |
isImmediate |
c48d8c45c740
isImmediate returns true for shared characters
Claus Gittinger <cg@exept.de>
parents:
5471
diff
changeset
|
1681 |
"return true if I am an immediate object |
c48d8c45c740
isImmediate returns true for shared characters
Claus Gittinger <cg@exept.de>
parents:
5471
diff
changeset
|
1682 |
i.e. I am represented in the pointer itself and |
c48d8c45c740
isImmediate returns true for shared characters
Claus Gittinger <cg@exept.de>
parents:
5471
diff
changeset
|
1683 |
no real object header/storage is used me. |
9153 | 1684 |
For VW compatibility, shared characters (i.e. in the range 0..MAX_IMMEDIATE_CHARACTER) |
5473
c48d8c45c740
isImmediate returns true for shared characters
Claus Gittinger <cg@exept.de>
parents:
5471
diff
changeset
|
1685 |
also return true here" |
9153 | 1686 |
|
8097 | 1687 |
%{ /* NOCONTEXT */ |
1688 |
if (__smallIntegerVal(__INST(asciivalue)) <= MAX_IMMEDIATE_CHARACTER) { |
|
9153 | 1689 |
RETURN ( true ); |
8097 | 1690 |
} |
1691 |
%}. |
|
1692 |
^ false |
|
1693 |
||
1694 |
" |
|
9153 | 1695 |
$a isImmediate. |
1696 |
(Character value:255) isImmediate. |
|
1697 |
(Character value:256) isImmediate. |
|
1698 |
(Character value:1566) isImmediate. |
|
8097 | 1699 |
" |
5473
c48d8c45c740
isImmediate returns true for shared characters
Claus Gittinger <cg@exept.de>
parents:
5471
diff
changeset
|
1700 |
! |
c48d8c45c740
isImmediate returns true for shared characters
Claus Gittinger <cg@exept.de>
parents:
5471
diff
changeset
|
1701 |
|
1 | 1702 |
isLetter |
7979
7515722ccfb1
isUppercase / isLowercase fix for division character.
Claus Gittinger <cg@exept.de>
parents:
7976
diff
changeset
|
1703 |
"return true, if I am a letter in the 'a'..'z' range. |
7515722ccfb1
isUppercase / isLowercase fix for division character.
Claus Gittinger <cg@exept.de>
parents:
7976
diff
changeset
|
1704 |
Use isNationalLetter, if you are interested in those." |
1 | 1705 |
|
7980 | 1706 |
%{ /* NOCONTEXT */ |
1 | 1707 |
|
1708 |
REGISTER int val; |
|
1709 |
||
1133 | 1710 |
val = __intVal(__INST(asciivalue)); |
6527 | 1711 |
if ((unsigned)(val - 'a') <= ('z' - 'a')) { |
9153 | 1712 |
RETURN ( true ); |
6527 | 1713 |
} |
1714 |
if ((unsigned)(val - 'A') <= ('Z' - 'A')) { |
|
9153 | 1715 |
RETURN ( true ); |
6527 | 1716 |
} |
1717 |
RETURN ( false ); |
|
5423
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1718 |
%}. |
8097 | 1719 |
^ (asciivalue between:($a codePoint) and:($z codePoint)) |
1720 |
or:[(asciivalue between:($A codePoint) and:($Z codePoint))] |
|
1 | 1721 |
! |
1722 |
||
154 | 1723 |
isLetterOrDigit |
7979
7515722ccfb1
isUppercase / isLowercase fix for division character.
Claus Gittinger <cg@exept.de>
parents:
7976
diff
changeset
|
1724 |
"return true, if I am a letter (a..z or A..Z) or a digit (0..9) |
7515722ccfb1
isUppercase / isLowercase fix for division character.
Claus Gittinger <cg@exept.de>
parents:
7976
diff
changeset
|
1725 |
Use isNationalAlphaNumeric, if you are interested in those." |
1 | 1726 |
|
1727 |
%{ /* NOCONTEXT */ |
|
1728 |
||
1729 |
REGISTER int val; |
|
1730 |
||
1133 | 1731 |
val = __intVal(__INST(asciivalue)); |
6527 | 1732 |
if ((unsigned)(val - 'a') <= ('z' - 'a')) { |
9153 | 1733 |
RETURN ( true ); |
1 | 1734 |
} |
6527 | 1735 |
if ((unsigned)(val - 'A') <= ('Z' - 'A')) { |
9153 | 1736 |
RETURN ( true ); |
1 | 1737 |
} |
6527 | 1738 |
if ((unsigned)(val - '0') <= ('9' - '0')) { |
9153 | 1739 |
RETURN ( true ); |
1 | 1740 |
} |
1741 |
RETURN ( false ); |
|
5423
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1742 |
%}. |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1743 |
^ self isLetter or:[self isDigit] |
1 | 1744 |
! |
1745 |
||
699 | 1746 |
isLowercase |
7979
7515722ccfb1
isUppercase / isLowercase fix for division character.
Claus Gittinger <cg@exept.de>
parents:
7976
diff
changeset
|
1747 |
"return true, if I am a lower-case letter. |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
1748 |
This one does care for national characters. |
9153 | 1749 |
Caveat: |
1750 |
only returns the correct value for codes up to u+1d6ff (Unicode3.1). |
|
1751 |
(which is more than mozilla does, btw. ;-)" |
|
699 | 1752 |
|
1753 |
%{ /* NOCONTEXT */ |
|
1754 |
||
1755 |
REGISTER int val; |
|
7989
7907420b2fab
asUppercase / asLowercase for U0100..U04FF
Claus Gittinger <cg@exept.de>
parents:
7988
diff
changeset
|
1756 |
#define TRUE_IF_ODD(x) ((x & 1) ? true : false) |
7907420b2fab
asUppercase / asLowercase for U0100..U04FF
Claus Gittinger <cg@exept.de>
parents:
7988
diff
changeset
|
1757 |
#define TRUE_IF_EVEN(x) ((x & 1) ? false : true) |
154 | 1758 |
|
1133 | 1759 |
val = __intVal(__INST(asciivalue)); |
7989
7907420b2fab
asUppercase / asLowercase for U0100..U04FF
Claus Gittinger <cg@exept.de>
parents:
7988
diff
changeset
|
1760 |
switch (val >> 8) { |
9153 | 1761 |
case 0x00: |
1762 |
if ((unsigned)(val - 'a') <= ('z' - 'a')) { |
|
1763 |
RETURN ( true ); |
|
1764 |
} |
|
1765 |
||
1766 |
/* iso8859 puts national lower case characters at e0 .. ff */ |
|
1767 |
if ((val >= 0xDF) && (val <= 0xFF)) { |
|
1768 |
if (val != 0xF7) { |
|
1769 |
RETURN(true); |
|
1770 |
} |
|
1771 |
} |
|
1772 |
if (val == 0xAA) RETURN(true); /* FEMININE ORDINAL INDICATOR (high a-underline) */ |
|
1773 |
if (val == 0xB5) RETURN(true); /* MICRO SIGN */ |
|
1774 |
if (val == 0xBA) RETURN(true); /* MASCULINE ORDINAL INDICATOR (high o-underline) */ |
|
1775 |
RETURN (false); |
|
1776 |
||
1777 |
case 0x01: |
|
1778 |
if (val <= 0x0137) { RETURN (TRUE_IF_ODD(val)); } |
|
1779 |
if (val <= 0x0148) { RETURN (TRUE_IF_EVEN(val)); } |
|
1780 |
if (val <= 0x0178) { RETURN (TRUE_IF_ODD(val)); } |
|
1781 |
if (val <= 0x017E) { RETURN (TRUE_IF_EVEN(val)); } |
|
1782 |
if (val <= 0x0180) { RETURN (true); } |
|
1783 |
if (val < 0x01CD) { |
|
1784 |
if (val == 0x0181) { RETURN (false); } |
|
1785 |
if (val <= 0x0185) { |
|
1786 |
RETURN (TRUE_IF_ODD(val)); |
|
1787 |
} |
|
1788 |
if (val == 0x0188) { RETURN (true); } |
|
1789 |
if (val == 0x018C) { RETURN (true); } |
|
1790 |
if (val == 0x018D) { RETURN (true); } |
|
1791 |
if (val == 0x0192) { RETURN (true); } |
|
1792 |
if (val == 0x0195) { RETURN (true); } |
|
1793 |
if (val == 0x0199) { RETURN (true); } |
|
1794 |
if (val == 0x019A) { RETURN (true); } |
|
1795 |
if (val == 0x019B) { RETURN (true); } |
|
1796 |
if (val == 0x019E) { RETURN (true); } |
|
1797 |
if (val <= 0x01A0) { RETURN (false); } |
|
1798 |
if (val <= 0x01A6) { RETURN (TRUE_IF_ODD(val)); } |
|
1799 |
if (val <= 0x01AA) { RETURN (TRUE_IF_EVEN(val)); } |
|
1800 |
if (val <= 0x01AE) { RETURN (TRUE_IF_ODD(val)); } |
|
1801 |
if (val == 0x01B2) { RETURN (false); } |
|
1802 |
if (val <= 0x01B6) { RETURN (TRUE_IF_EVEN(val)); } |
|
1803 |
if (val == 0x01B9) { RETURN (true); } |
|
1804 |
if (val == 0x01BA) { RETURN (true); } |
|
1805 |
if (val == 0x01BD) { RETURN (true); } |
|
1806 |
if (val == 0x01BE) { RETURN (true); } |
|
1807 |
if (val == 0x01BF) { RETURN (true); } |
|
1808 |
if (val == 0x01C6) { RETURN (true); } |
|
1809 |
if (val == 0x01C9) { RETURN (true); } |
|
1810 |
if (val == 0x01CC) { RETURN (true); } |
|
1811 |
RETURN (false); |
|
1812 |
} |
|
1813 |
if (val <= 0x01DC) { RETURN (TRUE_IF_EVEN(val)); } |
|
1814 |
if (val <= 0x01EF) { RETURN (TRUE_IF_ODD(val)); } |
|
1815 |
if (val == 0x01F0) { RETURN (true); } |
|
1816 |
if (val == 0x01F1) { RETURN (false); } |
|
1817 |
if (val == 0x01F2) { RETURN (false); } |
|
1818 |
if (val == 0x01F3) { RETURN (true); } |
|
1819 |
if (val <= 0x01F6) { RETURN (TRUE_IF_ODD(val)); } |
|
1820 |
if (val == 0x01F7) { RETURN (false); } |
|
1821 |
RETURN (TRUE_IF_ODD(val)); |
|
1822 |
||
1823 |
case 0x02: |
|
1824 |
if (val <= 0x0233) { RETURN (TRUE_IF_ODD(val)); } |
|
1825 |
if (val <= 0x0236) { RETURN (true); } |
|
1826 |
if (val < 0x0250) { RETURN (false); } |
|
1827 |
if (val < 0x02B0) { RETURN (true); } |
|
1828 |
RETURN (false); |
|
1829 |
||
1830 |
||
1831 |
case 0x03: |
|
1832 |
if (val == 0x0390) { RETURN (true); } |
|
1833 |
if (val <= 0x03AB) { RETURN (false); } |
|
1834 |
if (val <= 0x03D1) { RETURN (true); } |
|
1835 |
if (val == 0x03D5) { RETURN (true); } |
|
1836 |
if (val == 0x03D6) { RETURN (true); } |
|
1837 |
if (val < 0x03D7) { RETURN (false); } |
|
1838 |
if (val <= 0x03EF) { RETURN (TRUE_IF_ODD(val)); } |
|
1839 |
if (val <= 0x03F3) { RETURN (true); } |
|
1840 |
if (val == 0x03F5) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1841 |
#ifndef UNICODE_3_2 |
9153 | 1842 |
if (val == 0x03F8) { RETURN (true); } |
1843 |
if (val == 0x03FB) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1844 |
#endif |
9153 | 1845 |
RETURN (false); |
1846 |
||
1847 |
case 0x04: |
|
1848 |
if (val <= 0x042F) { RETURN (false); } |
|
1849 |
if (val <= 0x045F) { RETURN (true); } |
|
1850 |
if (val <= 0x0481) { RETURN (TRUE_IF_ODD(val)); } |
|
1851 |
if (val < 0x048A) { RETURN (false); } |
|
1852 |
if (val <= 0x04C0) { RETURN (TRUE_IF_ODD(val)); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1853 |
#ifdef UNICODE_3_2 |
9153 | 1854 |
if (val == 0x04C5) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1855 |
#endif |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1856 |
#ifdef UNICODE_3_2 |
9153 | 1857 |
if (val <= 0x04C8) { RETURN (TRUE_IF_EVEN(val)); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1858 |
#else |
9153 | 1859 |
if (val <= 0x04CA) { RETURN (TRUE_IF_EVEN(val)); } |
1860 |
if (val == 0x04CD) { RETURN (false); } |
|
1861 |
if (val == 0x04CE) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1862 |
#endif |
9153 | 1863 |
if (val == 0x04CB) { RETURN (false); } |
1864 |
if (val == 0x04CC) { RETURN (true); } |
|
1865 |
RETURN (TRUE_IF_ODD(val)); |
|
1866 |
||
1867 |
case 0x05: |
|
1868 |
if (val <= 0x050F) { RETURN (TRUE_IF_ODD(val)); } |
|
1869 |
if (val < 0x0561) { RETURN (false); } |
|
1870 |
if (val <= 0x0587) { RETURN (true); } |
|
1871 |
RETURN (false); |
|
1872 |
||
1873 |
case 0x1D: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1874 |
#ifndef UNICODE_3_2 |
9153 | 1875 |
if (val <= 0x1D2B) { RETURN (true); } |
1876 |
if (val <= 0x1D61) { RETURN (false); } |
|
1877 |
if (val <= 0x1D70) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1878 |
#endif |
9153 | 1879 |
RETURN (false); |
1880 |
||
1881 |
case 0x1E: |
|
1882 |
if (val < 0x1E96) { RETURN (TRUE_IF_ODD(val)); } |
|
1883 |
if (val <= 0x1E9F) { RETURN (true); } |
|
1884 |
RETURN (TRUE_IF_ODD(val)); |
|
1885 |
||
1886 |
case 0x1F: |
|
1887 |
if (val <= 0x1F6F) { |
|
1888 |
if (val & 0x0008) { RETURN (false); } |
|
1889 |
RETURN (true); |
|
1890 |
} |
|
1891 |
if (val <= 0x1F87) { RETURN (true); } |
|
1892 |
if (val < 0x1FB8) { |
|
1893 |
if (val & 0x0008) { RETURN (false); } |
|
1894 |
RETURN (true); |
|
1895 |
} |
|
1896 |
if (val == 0x1FBE) { RETURN (true); } |
|
1897 |
if (val == 0x1FD4) { RETURN (false); } |
|
1898 |
if (val == 0x1FC5) { RETURN (false); } |
|
1899 |
if (val == 0x1FD5) { RETURN (false); } |
|
1900 |
if (val == 0x1FC1) { RETURN (false); } |
|
1901 |
if (val == 0x1FF1) { RETURN (false); } |
|
1902 |
if (val == 0x1FC0) { RETURN (false); } |
|
1903 |
if (val == 0x1FF0) { RETURN (false); } |
|
1904 |
if (((val & 0x000F) >= 0x0000) && ((val & 0x000F) <= 0x0007)) { RETURN (true); } |
|
1905 |
RETURN (false); |
|
1906 |
||
1907 |
case 0x20: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1908 |
#ifndef UNICODE_3_2 |
9153 | 1909 |
if (val == 0x2071) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1910 |
#endif |
9153 | 1911 |
if (val == 0x207F) { RETURN (true); } |
1912 |
RETURN (false); |
|
1913 |
||
1914 |
case 0x21: |
|
1915 |
if (val == 0x210A) { RETURN (true); } |
|
1916 |
if (val < 0x210E) { RETURN (false); } |
|
1917 |
if (val <= 0x210F) { RETURN (true); } |
|
1918 |
if (val == 0x2113) { RETURN (true); } |
|
1919 |
if (val == 0x212F) { RETURN (true); } |
|
1920 |
if (val == 0x2134) { RETURN (true); } |
|
1921 |
if (val == 0x2139) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1922 |
#ifndef UNICODE_3_2 |
9153 | 1923 |
if (val == 0x213D) { RETURN (true); } |
1924 |
if (val <= 0x2145) { RETURN (false); } |
|
1925 |
if (val <= 0x2149) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1926 |
#endif |
9153 | 1927 |
RETURN (false); |
1928 |
||
1929 |
case 0xFB: |
|
1930 |
if (val <= 0xFB1C) { RETURN (true); } |
|
1931 |
RETURN (false); |
|
1932 |
||
1933 |
case 0xFF: |
|
1934 |
if ((val >= 0xFF41) && (val <= 0xFF5A)) { RETURN (true); } |
|
1935 |
RETURN (false); |
|
1936 |
||
1937 |
case 0x104: |
|
1938 |
if (val <= 0x10427) { RETURN (false); } |
|
1939 |
if (val <= 0x1044D) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1940 |
#ifdef UNICODE_3_2 |
9153 | 1941 |
if (val <= 0x1044D) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1942 |
#else |
9153 | 1943 |
if (val <= 0x1044F) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
1944 |
#endif |
9153 | 1945 |
RETURN (false); |
1946 |
||
1947 |
case 0x1D4: |
|
1948 |
case 0x1D5: |
|
1949 |
case 0x1D6: |
|
1950 |
if (val <= 0x1D419) { RETURN (false); } |
|
1951 |
if (val < 0x1D6be) { |
|
1952 |
if (((val - 0x1D41A) % 52) <= 25) { RETURN (true); } |
|
1953 |
RETURN (false); |
|
1954 |
} |
|
1955 |
if (val < 0x1D6c2) { RETURN (false); } |
|
1956 |
if (val < 0x1D6db) { RETURN (true); } |
|
1957 |
if (val == 0x1D6db) { RETURN (false); } |
|
1958 |
if (val < 0x1D6e2) { RETURN (true); } |
|
1959 |
if (val <= 0x1D6fb) { RETURN (false); } |
|
1960 |
RETURN (true); |
|
699 | 1961 |
} |
7989
7907420b2fab
asUppercase / asLowercase for U0100..U04FF
Claus Gittinger <cg@exept.de>
parents:
7988
diff
changeset
|
1962 |
#undef TRUE_IF_ODD |
7907420b2fab
asUppercase / asLowercase for U0100..U04FF
Claus Gittinger <cg@exept.de>
parents:
7988
diff
changeset
|
1963 |
#undef TRUE_IF_EVEN |
7907420b2fab
asUppercase / asLowercase for U0100..U04FF
Claus Gittinger <cg@exept.de>
parents:
7988
diff
changeset
|
1964 |
RETURN (false); |
5423
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
1965 |
%}. |
154 | 1966 |
! |
1967 |
||
699 | 1968 |
isPrintable |
1969 |
"return true, if the receiver is a useful printable character |
|
1970 |
(see fileBrowsers showFile:-method on how it can be used)" |
|
1 | 1971 |
|
699 | 1972 |
(asciivalue between:32 and:127) ifTrue:[^ true]. |
6398 | 1973 |
asciivalue == 12 ifTrue:[^ true]. "/ FF |
1974 |
asciivalue == 13 ifTrue:[^ true]. "/ CR |
|
1975 |
asciivalue == 9 ifTrue:[^ true]. "/ TAB |
|
1976 |
asciivalue == 10 ifTrue:[^ true]. "/ NL |
|
2840 | 1977 |
|
8097 | 1978 |
(asciivalue between:16rA0 and:16rBF) ifTrue:[^ true]. "/ ISO-8859 |
1979 |
^ self isNationalAlphaNumeric |
|
2840 | 1980 |
|
1981 |
"Modified: 7.8.1997 / 17:05:24 / cg" |
|
1 | 1982 |
! |
1983 |
||
1984 |
isSeparator |
|
1985 |
"return true if I am a space, cr, tab, nl, or newPage" |
|
1986 |
||
1987 |
%{ /* NOCONTEXT */ |
|
1988 |
||
1989 |
REGISTER int val; |
|
1990 |
||
1133 | 1991 |
val = __intVal(__INST(asciivalue)); |
328 | 1992 |
#ifndef NON_ASCII /* i.e. EBCDIC ;-) */ |
1993 |
if (val <= ' ') |
|
1994 |
#endif |
|
9153 | 1995 |
if ((val == ' ') |
1996 |
|| (val == '\n') |
|
1997 |
|| (val == '\t') |
|
1998 |
|| (val == '\r') |
|
1999 |
|| (val == '\f')) { |
|
2000 |
RETURN ( true ); |
|
2001 |
} |
|
5423
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
2002 |
RETURN (false); |
9153 | 2003 |
%}. |
5423
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
2004 |
^ (asciivalue == 16r20) |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
2005 |
or:[asciivalue == 16r0D |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
2006 |
or:[asciivalue == 16r0A |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
2007 |
or:[asciivalue == 16r09 |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
2008 |
or:[asciivalue == 16r0C]]]] |
e33decc83182
non-primitive fallBack code added
Claus Gittinger <cg@exept.de>
parents:
5407
diff
changeset
|
2009 |
|
1 | 2010 |
! |
2011 |
||
699 | 2012 |
isUppercase |
7979
7515722ccfb1
isUppercase / isLowercase fix for division character.
Claus Gittinger <cg@exept.de>
parents:
7976
diff
changeset
|
2013 |
"return true, if I am an upper-case letter. |
8022
d901d41171a5
isXXX and asXXX are now valid up to U+1d6FF
Claus Gittinger <cg@exept.de>
parents:
8012
diff
changeset
|
2014 |
This one does care for national characters. |
9153 | 2015 |
Caveat: |
2016 |
only returns the correct value for codes up to u+1d6ff (Unicode3.1). |
|
2017 |
(which is more than mozilla does, btw. ;-)" |
|
1 | 2018 |
|
2019 |
%{ /* NOCONTEXT */ |
|
7988
cb1c920e67eb
isUppercase / isLowercase unicode changes
Claus Gittinger <cg@exept.de>
parents:
7987
diff
changeset
|
2020 |
#define TRUE_IF_ODD(x) ((x & 1) ? true : false) |
cb1c920e67eb
isUppercase / isLowercase unicode changes
Claus Gittinger <cg@exept.de>
parents:
7987
diff
changeset
|
2021 |
#define TRUE_IF_EVEN(x) ((x & 1) ? false : true) |
1 | 2022 |
|
2023 |
REGISTER int val; |
|
2024 |
||
1133 | 2025 |
val = __intVal(__INST(asciivalue)); |
7979
7515722ccfb1
isUppercase / isLowercase fix for division character.
Claus Gittinger <cg@exept.de>
parents:
7976
diff
changeset
|
2026 |
|
7988
cb1c920e67eb
isUppercase / isLowercase unicode changes
Claus Gittinger <cg@exept.de>
parents:
7987
diff
changeset
|
2027 |
switch (val >> 8) { |
9153 | 2028 |
case 0x00: |
2029 |
if ((unsigned)(val - 'A') <= ('Z' - 'A')) { |
|
2030 |
RETURN ( true ); |
|
2031 |
} |
|
2032 |
/* iso8859 puts national upper case characters at c0 .. df */ |
|
2033 |
if ((val >= 0xC0) && (val <= 0xDE)) { |
|
2034 |
if (val != 0xD7) { |
|
2035 |
RETURN(true); |
|
2036 |
} |
|
2037 |
} |
|
2038 |
RETURN (false); |
|
2039 |
||
2040 |
case 0x01: |
|
2041 |
if (val <= 0x0137) { RETURN (TRUE_IF_EVEN(val)); } |
|
2042 |
if (val <= 0x0148) { RETURN (TRUE_IF_ODD(val)); } |
|
2043 |
if (val <= 0x0178) { RETURN (TRUE_IF_EVEN(val)); } |
|
2044 |
if (val <= 0x017E) { RETURN (TRUE_IF_ODD(val)); } |
|
2045 |
if (val < 0x01CD) { |
|
2046 |
if (val == 0x0180) { RETURN (false); } |
|
2047 |
if (val == 0x0181) { RETURN (true); } |
|
2048 |
if (val <= 0x0186) { |
|
2049 |
RETURN (TRUE_IF_EVEN(val)); |
|
2050 |
} |
|
2051 |
if (val <= 0x0189) { |
|
2052 |
RETURN (TRUE_IF_ODD(val)); |
|
2053 |
} |
|
2054 |
if (val <= 0x018B) { RETURN (true); } |
|
2055 |
if (val <= 0x018D) { RETURN (false); } |
|
2056 |
if (val <= 0x0191) { RETURN (true); } |
|
2057 |
if (val == 0x0193) { RETURN (true); } |
|
2058 |
if (val == 0x0194) { RETURN (true); } |
|
2059 |
if (val == 0x0196) { RETURN (true); } |
|
2060 |
if (val == 0x0197) { RETURN (true); } |
|
2061 |
if (val == 0x0198) { RETURN (true); } |
|
2062 |
if (val == 0x019C) { RETURN (true); } |
|
2063 |
if (val == 0x019D) { RETURN (true); } |
|
2064 |
if (val == 0x019F) { RETURN (true); } |
|
2065 |
if (val < 0x01A0) { RETURN (false); } |
|
2066 |
if (val <= 0x01A6) { RETURN (TRUE_IF_EVEN(val)); } |
|
2067 |
if (val <= 0x01AA) { RETURN (TRUE_IF_ODD(val)); } |
|
2068 |
if (val <= 0x01AE) { RETURN (TRUE_IF_EVEN(val)); } |
|
2069 |
if (val == 0x01B2) { RETURN (true); } |
|
2070 |
if (val <= 0x01B7) { RETURN (TRUE_IF_ODD(val)); } |
|
2071 |
if (val == 0x01B8) { RETURN (true); } |
|
2072 |
if (val == 0x01BC) { RETURN (true); } |
|
2073 |
if (val == 0x01C4) { RETURN (true); } |
|
2074 |
if (val == 0x01C7) { RETURN (true); } |
|
8308 | 2075 |
#if 0 |
9153 | 2076 |
if (val == 0x01C8) { RETURN (true); } |
8308 | 2077 |
#endif |
9153 | 2078 |
if (val == 0x01CA) { RETURN (true); } |
8308 | 2079 |
#if 0 |
9153 | 2080 |
if (val == 0x01CB) { RETURN (true); } |
8308 | 2081 |
#endif |
9153 | 2082 |
RETURN (false); /* WRONG !!! */ |
2083 |
} |
|
2084 |
if (val <= 0x01DC) { RETURN (TRUE_IF_ODD(val)); } |
|
2085 |
if (val <= 0x01EF) { RETURN (TRUE_IF_EVEN(val)); } |
|
2086 |
if (val == 0x01F0) { RETURN (false); } |
|
2087 |
if (val == 0x01F1) { RETURN (true); } |
|
2088 |
if (val == 0x01F2) { RETURN (false); } |
|
2089 |
if (val == 0x01F3) { RETURN (false); } |
|
2090 |
if (val == 0x01F4) { RETURN (true); } |
|
2091 |
if (val == 0x01F5) { RETURN (false); } |
|
2092 |
if (val == 0x01F6) { RETURN (true); } |
|
2093 |
if (val == 0x01F7) { RETURN (true); } |
|
2094 |
RETURN (TRUE_IF_EVEN(val)); |
|
2095 |
||
2096 |
case 0x02: |
|
2097 |
if (val <= 0x0233) { RETURN (TRUE_IF_EVEN(val)); } |
|
2098 |
RETURN (false); |
|
2099 |
||
2100 |
case 0x03: |
|
2101 |
if (val < 0x0386) { RETURN (false); } |
|
2102 |
if (val == 0x0387) { RETURN (false); } |
|
2103 |
if (val == 0x0390) { RETURN (false); } |
|
2104 |
if (val <= 0x03AB) { RETURN (true); } |
|
2105 |
if (val <= 0x03D1) { RETURN (false); } |
|
2106 |
if (val <= 0x03D4) { RETURN (true); } |
|
2107 |
if (val <= 0x03D7) { RETURN (false); } |
|
2108 |
if (val <= 0x03EF) { RETURN (TRUE_IF_EVEN(val)); } |
|
2109 |
if (val == 0x03F4) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2110 |
#ifndef UNICODE_3_2 |
9153 | 2111 |
if (val == 0x03F7) { RETURN (true); } |
2112 |
if (val == 0x03F9) { RETURN (true); } |
|
2113 |
if (val == 0x03Fa) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2114 |
#endif |
9153 | 2115 |
RETURN (false); |
2116 |
||
2117 |
case 0x04: |
|
2118 |
if (val <= 0x042F) { RETURN (true); } |
|
2119 |
if (val <= 0x045F) { RETURN (false); } |
|
2120 |
if (val <= 0x0481) { RETURN (TRUE_IF_EVEN(val)); } |
|
2121 |
if (val < 0x048A) { RETURN (false); } |
|
2122 |
if (val <= 0x04C0) { RETURN (TRUE_IF_EVEN(val)); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2123 |
#ifdef UNICODE_3_2 |
9153 | 2124 |
if (val == 0x04C5) { RETURN (false); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2125 |
#endif |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2126 |
#ifdef UNICODE_3_2 |
9153 | 2127 |
if (val <= 0x04C8) { RETURN (TRUE_IF_ODD(val)); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2128 |
#else |
9153 | 2129 |
if (val <= 0x04CA) { RETURN (TRUE_IF_ODD(val)); } |
2130 |
if (val == 0x04CD) { RETURN (true); } |
|
2131 |
if (val == 0x04CE) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2132 |
#endif |
9153 | 2133 |
if (val == 0x04CB) { RETURN (true); } |
2134 |
if (val == 0x04CC) { RETURN (false); } |
|
2135 |
RETURN (TRUE_IF_EVEN(val)); |
|
2136 |
||
2137 |
case 0x05: |
|
2138 |
if (val <= 0x050F) { RETURN (TRUE_IF_EVEN(val)); } |
|
2139 |
if (val < 0x0531) { RETURN (false); } |
|
2140 |
if (val <= 0x0556) { RETURN (true); } |
|
2141 |
RETURN (false); |
|
2142 |
||
2143 |
case 0x10: |
|
2144 |
if (val < 0x10A0) { RETURN (false); } |
|
2145 |
if (val <= 0x10CF) { RETURN (true); } |
|
2146 |
RETURN (false); |
|
2147 |
||
2148 |
case 0x1E: |
|
2149 |
if (val < 0x1E96) { RETURN (TRUE_IF_EVEN(val)); } |
|
2150 |
if (val < 0x1EA0) { RETURN (false); } |
|
2151 |
RETURN (TRUE_IF_EVEN(val)); |
|
2152 |
||
2153 |
case 0x1F: |
|
2154 |
if (val <= 0x1F6F) { |
|
2155 |
if (val & 0x0008) { RETURN (true); } |
|
2156 |
} |
|
2157 |
if (val <= 0x1F87) { RETURN (false); } |
|
2158 |
if (val < 0x1FB8) { RETURN (false); } |
|
2159 |
if (val < 0x1FBC) { RETURN (true); } |
|
2160 |
if (val == 0x1FEC) { RETURN (true); } |
|
2161 |
if (((val & 0x000F) >= 0x0008) && ((val & 0x000F) <= 0x000B)) { RETURN (true); } |
|
2162 |
RETURN (false); |
|
2163 |
||
2164 |
case 0x21: |
|
2165 |
if (val == 0x2102) { RETURN (true); } |
|
2166 |
if (val == 0x2107) { RETURN (true); } |
|
2167 |
if (val < 0x210B) { RETURN (false); } |
|
2168 |
if (val < 0x210E) { RETURN (true); } |
|
2169 |
if (val == 0x2110) { RETURN (true); } |
|
2170 |
if (val == 0x2111) { RETURN (true); } |
|
2171 |
if (val == 0x2112) { RETURN (true); } |
|
2172 |
if (val == 0x2115) { RETURN (true); } |
|
2173 |
if (val == 0x2119) { RETURN (true); } |
|
2174 |
if (val == 0x211A) { RETURN (true); } |
|
2175 |
if (val == 0x211B) { RETURN (true); } |
|
2176 |
if (val == 0x211C) { RETURN (true); } |
|
2177 |
if (val == 0x211D) { RETURN (true); } |
|
2178 |
if (val < 0x2124) { RETURN (false); } |
|
2179 |
if (val <= 0x212A) { RETURN (TRUE_IF_EVEN(val)); } |
|
2180 |
if (val == 0x212B) { RETURN (true); } |
|
2181 |
if (val == 0x212C) { RETURN (true); } |
|
2182 |
if (val == 0x212D) { RETURN (true); } |
|
2183 |
if (val == 0x2130) { RETURN (true); } |
|
2184 |
if (val == 0x2131) { RETURN (true); } |
|
2185 |
if (val == 0x2133) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2186 |
#ifndef UNICODE_3_2 |
9153 | 2187 |
if (val == 0x213E) { RETURN (true); } |
2188 |
if (val == 0x213F) { RETURN (true); } |
|
2189 |
if (val == 0x2145) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2190 |
#endif |
9153 | 2191 |
RETURN (false); |
2192 |
||
2193 |
case 0xFF: |
|
2194 |
if ((val >= 0xFF21) && (val <= 0xFF3A)) { RETURN (true); } |
|
2195 |
RETURN (false); |
|
2196 |
||
2197 |
case 0x104: |
|
2198 |
if (val <= 0x10427) { RETURN (true); } |
|
2199 |
RETURN (false); |
|
2200 |
||
2201 |
case 0x1D4: |
|
2202 |
case 0x1D5: |
|
2203 |
case 0x1D6: |
|
2204 |
if (val <= 0x1D419) { RETURN (true); } |
|
2205 |
if (val < 0x1D6be) { |
|
2206 |
if (((val - 0x1D41A) % 52) <= 25) { RETURN (false); } |
|
2207 |
RETURN (true); |
|
2208 |
} |
|
2209 |
if (val < 0x1D6c1) { RETURN (true); } |
|
2210 |
if (val < 0x1D6e2) { RETURN (false); } |
|
2211 |
if (val < 0x1D6fb) { RETURN (true); } |
|
2212 |
||
2213 |
RETURN (false); |
|
7979
7515722ccfb1
isUppercase / isLowercase fix for division character.
Claus Gittinger <cg@exept.de>
parents:
7976
diff
changeset
|
2214 |
} |
7988
cb1c920e67eb
isUppercase / isLowercase unicode changes
Claus Gittinger <cg@exept.de>
parents:
7987
diff
changeset
|
2215 |
RETURN (false); |
7985 | 2216 |
|
9153 | 2217 |
#undef TRUE_IF_ODD |
2218 |
#undef TRUE_IF_EVEN |
|
7988
cb1c920e67eb
isUppercase / isLowercase unicode changes
Claus Gittinger <cg@exept.de>
parents:
7987
diff
changeset
|
2219 |
%} |
1 | 2220 |
! |
2221 |
||
699 | 2222 |
isVowel |
2223 |
"return true, if I am a vowel (lower- or uppercase)" |
|
333 | 2224 |
|
6066 | 2225 |
"/ I know the code is ugly; |
2226 |
"/ better code is: |
|
2227 |
"/ 'aeiou' includes:self asLowercase |
|
2228 |
"/ or: |
|
2229 |
"/ 'aeiouAEIOU' includes:self |
|
2230 |
"/ |
|
2231 |
"/ until I have a smart compiler, I use the shorter (codewise): |
|
2232 |
||
699 | 2233 |
(self == $a) ifTrue:[^ true]. |
2234 |
(self == $e) ifTrue:[^ true]. |
|
2235 |
(self == $i) ifTrue:[^ true]. |
|
2236 |
(self == $o) ifTrue:[^ true]. |
|
2237 |
(self == $u) ifTrue:[^ true]. |
|
2238 |
(self == $A) ifTrue:[^ true]. |
|
2239 |
(self == $E) ifTrue:[^ true]. |
|
2240 |
(self == $I) ifTrue:[^ true]. |
|
2241 |
(self == $O) ifTrue:[^ true]. |
|
2242 |
(self == $U) ifTrue:[^ true]. |
|
2243 |
^ false |
|
1 | 2244 |
! ! |
699 | 2245 |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2246 |
!Character methodsFor:'testing - national'! |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2247 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2248 |
isNationalAlphaNumeric |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2249 |
"return true, if the receiver is a letter or digit in the |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2250 |
current language (Language variable)" |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2251 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2252 |
self isNationalLetter ifTrue:[^ true]. |
9153 | 2253 |
^ self isNationalDigit |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2254 |
! |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2255 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2256 |
isNationalDigit |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2257 |
"return true, if the receiver is a digit. |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2258 |
This assumes unicode encoding. |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2259 |
WARNING: this method is not complete." |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2260 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2261 |
|codePoint "{ Class SmallInteger }"| |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2262 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2263 |
codePoint := asciivalue. |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2264 |
|
9153 | 2265 |
codePoint <= 16rFF ifTrue:[ "/ u00xx - unicode latin1 page |
2266 |
(codePoint between:($0 codePoint) and:($9 codePoint)) ifTrue:[^ true]. |
|
2267 |
^ false |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2268 |
]. |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2269 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2270 |
(codePoint between:16rFF10 and:16rFF19) ifTrue:[ ^ true]. |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2271 |
^ false. |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2272 |
! |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2273 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2274 |
isNationalLetter |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2275 |
"return true, if the receiver is a letter. |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2276 |
CAVEAT: |
9153 | 2277 |
for now, this method is only correct for unicode characters up to u+1d6ff (Unicode3.1). |
2278 |
(which is more than mozilla does, btw. ;-)" |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2279 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2280 |
%{ /* NOCONTEXT */ |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2281 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2282 |
REGISTER int val; |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2283 |
|
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2284 |
val = __intVal(__INST(asciivalue)); |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2285 |
switch (val >> 8) { |
9153 | 2286 |
case 0x00: |
2287 |
if ((unsigned)(val - 'A') <= ('Z' - 'A')) { |
|
2288 |
RETURN ( true ); |
|
2289 |
} |
|
2290 |
if ((unsigned)(val - 'a') <= ('z' - 'a')) { |
|
2291 |
RETURN ( true ); |
|
2292 |
} |
|
2293 |
if (val == 0xAA) { RETURN (true); } |
|
2294 |
if (val == 0xB5) { RETURN (true); } |
|
2295 |
if (val == 0xBA) { RETURN (true); } |
|
2296 |
if (val < 0xC0) { RETURN (false); } |
|
2297 |
if (val == 0xD7) { RETURN (false); } |
|
2298 |
if (val == 0xF7) { RETURN (false); } |
|
2299 |
RETURN (true); |
|
2300 |
||
2301 |
case 0x01: |
|
2302 |
RETURN (true); |
|
2303 |
||
2304 |
case 0x02: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2305 |
#ifdef UNICODE_3_2 |
9153 | 2306 |
if (val <= 0x2B8) { RETURN (true); } |
2307 |
if (val == 0x2B9) { RETURN (false); } |
|
2308 |
if (val == 0x2BA) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2309 |
#else |
9153 | 2310 |
if (val <= 0x2BA) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2311 |
#endif |
9153 | 2312 |
if (val <= 0x2C1) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2313 |
#ifndef UNICODE_3_2 |
9153 | 2314 |
if (val <= 0x2C5) { RETURN (false); } |
2315 |
if (val <= 0x2CF) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2316 |
#endif |
9153 | 2317 |
if (val == 0x2D0) { RETURN (true); } |
2318 |
if (val == 0x2D1) { RETURN (true); } |
|
2319 |
if (val <= 0x2DF) { RETURN (false); } |
|
2320 |
if (val <= 0x2E4) { RETURN (true); } |
|
2321 |
if (val == 0x2EE) { RETURN (true); } |
|
2322 |
RETURN (false); |
|
2323 |
||
2324 |
case 0x03: |
|
2325 |
if (val == 0x37A) { RETURN (true); } |
|
2326 |
if (val <= 0x385) { RETURN (false); } |
|
2327 |
if (val == 0x387) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2328 |
#ifndef UNICODE_3_2 |
9153 | 2329 |
if (val == 0x3F6) { RETURN (false); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2330 |
#endif |
9153 | 2331 |
RETURN (true); |
2332 |
||
2333 |
case 0x04: |
|
2334 |
if (val <= 0x481) { RETURN (true); } |
|
2335 |
if (val <= 0x486) { RETURN (false); } |
|
2336 |
if (val == 0x487) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2337 |
#ifdef UNICODE_3_2 |
9153 | 2338 |
if (val <= 0x48A) { RETURN (false); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2339 |
#else |
9153 | 2340 |
if (val <= 0x489) { RETURN (false); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2341 |
#endif |
9153 | 2342 |
RETURN (true); |
2343 |
||
2344 |
case 0x05: |
|
2345 |
if (val <= 0x50f) { RETURN (true); } |
|
2346 |
if (val <= 0x530) { RETURN (false); } |
|
2347 |
if (val <= 0x556) { RETURN (true); } |
|
2348 |
if (val <= 0x558) { RETURN (false); } |
|
2349 |
if (val <= 0x559) { RETURN (true); } |
|
2350 |
if (val <= 0x55F) { RETURN (false); } |
|
2351 |
if (val <= 0x587) { RETURN (true); } |
|
2352 |
if (val <= 0x5cf) { RETURN (false); } |
|
2353 |
if (val <= 0x5f2) { RETURN (true); } |
|
2354 |
RETURN (false); |
|
2355 |
||
2356 |
case 0x06: |
|
2357 |
if (val <= 0x620) { RETURN (false); } |
|
2358 |
if (val <= 0x64A) { RETURN (true); } |
|
2359 |
if (val <= 0x66D) { RETURN (false); } |
|
2360 |
if (val == 0x670) { RETURN (false); } |
|
2361 |
if (val <= 0x6D3) { RETURN (true); } |
|
2362 |
if (val == 0x6D5) { RETURN (true); } |
|
2363 |
if (val == 0x6E5) { RETURN (true); } |
|
2364 |
if (val == 0x6E6) { RETURN (true); } |
|
2365 |
if (val == 0x6EE) { RETURN (true); } |
|
2366 |
if (val == 0x6EF) { RETURN (true); } |
|
2367 |
if (val == 0x6FA) { RETURN (true); } |
|
2368 |
if (val == 0x6FB) { RETURN (true); } |
|
2369 |
if (val == 0x6FC) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2370 |
#ifndef UNICODE_3_2 |
9153 | 2371 |
if (val == 0x6FF) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2372 |
#endif |
9153 | 2373 |
RETURN (false); |
2374 |
||
2375 |
case 0x07: |
|
2376 |
if (val <= 0x70F) { RETURN (false); } |
|
2377 |
if (val == 0x711) { RETURN (false); } |
|
2378 |
if (val <= 0x72F) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2379 |
#ifdef UNICODE_3_2 |
9153 | 2380 |
if (val <= 0x74d) { RETURN (false); } |
2381 |
if (val <= 0x74e) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2382 |
#else |
9153 | 2383 |
if (val <= 0x74c) { RETURN (false); } |
2384 |
if (val <= 0x74f) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2385 |
#endif |
9153 | 2386 |
if (val <= 0x77F) { RETURN (false); } |
2387 |
if (val <= 0x7a5) { RETURN (true); } |
|
2388 |
if (val <= 0x7af) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2389 |
#ifndef UNICODE_3_2 |
9153 | 2390 |
if (val == 0x7B1) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2391 |
#endif |
9153 | 2392 |
RETURN (false); |
2393 |
||
2394 |
case 0x09: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2395 |
#ifdef UNICODE_3_2 |
9153 | 2396 |
if (val <= 0x904) { RETURN (false); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2397 |
#else |
9153 | 2398 |
if (val <= 0x903) { RETURN (false); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2399 |
#endif |
9153 | 2400 |
if (val <= 0x93B) { RETURN (true); } |
2401 |
if (val == 0x93D) { RETURN (true); } |
|
2402 |
if (val == 0x950) { RETURN (true); } |
|
2403 |
if (val <= 0x957) { RETURN (false); } |
|
2404 |
if (val <= 0x961) { RETURN (true); } |
|
2405 |
if (val <= 0x984) { RETURN (false); } |
|
2406 |
if (val <= 0x9BB) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2407 |
#ifndef UNICODE_3_2 |
9153 | 2408 |
if (val == 0x9BD) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2409 |
#endif |
9153 | 2410 |
if (val <= 0x9DB) { RETURN (false); } |
2411 |
if (val <= 0x9E1) { RETURN (true); } |
|
2412 |
if (val <= 0x9EF) { RETURN (false); } |
|
2413 |
if (val <= 0x9F1) { RETURN (true); } |
|
2414 |
RETURN (false); |
|
2415 |
||
2416 |
case 0x0A: |
|
2417 |
if (val <= 0xa04) { RETURN (false); } |
|
2418 |
if (val <= 0xa3B) { RETURN (true); } |
|
2419 |
if (val <= 0xa58) { RETURN (false); } |
|
2420 |
if (val <= 0xa65) { RETURN (true); } |
|
2421 |
if (val <= 0xa71) { RETURN (false); } |
|
2422 |
if (val <= 0xa80) { RETURN (true); } |
|
2423 |
if (val <= 0xa84) { RETURN (false); } |
|
2424 |
if (val <= 0xaBB) { RETURN (true); } |
|
2425 |
if (val == 0xaBD) { RETURN (true); } |
|
2426 |
if (val <= 0xaCF) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2427 |
#ifndef UNICODE_3_2 |
9153 | 2428 |
if (val == 0xAE2) { RETURN (false); } |
2429 |
if (val == 0xAE3) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2430 |
#endif |
9153 | 2431 |
if (val <= 0xaE5) { RETURN (true); } |
2432 |
RETURN (false); |
|
2433 |
||
2434 |
case 0x0B: |
|
2435 |
if (val <= 0xB04) { RETURN (false); } |
|
2436 |
if (val <= 0xb3B) { RETURN (true); } |
|
2437 |
if (val == 0xb3d) { RETURN (true); } |
|
2438 |
if (val <= 0xb5B) { RETURN (false); } |
|
2439 |
if (val <= 0xb65) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2440 |
#ifndef UNICODE_3_2 |
9153 | 2441 |
if (val == 0xB71) { RETURN (true); } |
2442 |
if (val == 0xB83) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2443 |
#endif |
9153 | 2444 |
if (val <= 0xb84) { RETURN (false); } |
2445 |
if (val <= 0xbBB) { RETURN (true); } |
|
2446 |
RETURN (false); |
|
2447 |
||
2448 |
case 0x0c: |
|
2449 |
if (val <= 0xc04) { RETURN (false); } |
|
2450 |
if (val <= 0xc3d) { RETURN (true); } |
|
2451 |
if (val <= 0xc5f) { RETURN (false); } |
|
2452 |
if (val <= 0xc65) { RETURN (true); } |
|
2453 |
if (val <= 0xc84) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2454 |
#ifndef UNICODE_3_2 |
9153 | 2455 |
if (val == 0xcbc) { RETURN (false); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2456 |
#endif |
9153 | 2457 |
if (val <= 0xcbd) { RETURN (true); } |
2458 |
if (val <= 0xcdc) { RETURN (false); } |
|
2459 |
if (val <= 0xce5) { RETURN (true); } |
|
2460 |
RETURN (false); |
|
2461 |
||
2462 |
case 0x0d: |
|
2463 |
if (val <= 0xd04) { RETURN (false); } |
|
2464 |
if (val <= 0xd3d) { RETURN (true); } |
|
2465 |
if (val <= 0xd5f) { RETURN (false); } |
|
2466 |
if (val <= 0xd65) { RETURN (true); } |
|
2467 |
if (val <= 0xd84) { RETURN (false); } |
|
2468 |
if (val <= 0xdc9) { RETURN (true); } |
|
2469 |
RETURN (false); |
|
2470 |
||
2471 |
case 0x0E: |
|
2472 |
if (val == 0xE31) { RETURN (false); } |
|
2473 |
if (val <= 0xE33) { RETURN (true); } |
|
2474 |
if (val <= 0xE3F) { RETURN (false); } |
|
2475 |
if (val <= 0xE46) { RETURN (true); } |
|
2476 |
if (val <= 0xE7f) { RETURN (false); } |
|
2477 |
if (val <= 0xEb0) { RETURN (true); } |
|
2478 |
if (val == 0xEb1) { RETURN (false); } |
|
2479 |
if (val <= 0xEb3) { RETURN (true); } |
|
2480 |
if (val <= 0xEbc) { RETURN (false); } |
|
2481 |
if (val <= 0xEc7) { RETURN (true); } |
|
2482 |
if (val <= 0xEdb) { RETURN (false); } |
|
2483 |
RETURN (true); |
|
2484 |
||
2485 |
case 0x0F: |
|
2486 |
if (val == 0xf00) { RETURN (true); } |
|
2487 |
if (val <= 0xf3F) { RETURN (false); } |
|
2488 |
if (val <= 0xf70) { RETURN (true); } |
|
2489 |
if (val <= 0xf87) { RETURN (false); } |
|
2490 |
if (val <= 0xf8f) { RETURN (true); } |
|
2491 |
RETURN (false); |
|
2492 |
||
2493 |
case 0x10: |
|
2494 |
if (val <= 0x102b) { RETURN (true); } |
|
2495 |
if (val <= 0x104f) { RETURN (false); } |
|
2496 |
if (val <= 0x1055) { RETURN (true); } |
|
2497 |
if (val <= 0x109f) { RETURN (false); } |
|
2498 |
if (val <= 0x10fa) { RETURN (true); } |
|
2499 |
RETURN (false); |
|
2500 |
||
2501 |
case 0x11: |
|
2502 |
case 0x12: |
|
2503 |
RETURN (true); |
|
2504 |
||
2505 |
case 0x13: |
|
2506 |
if (val <= 0x1360) { RETURN (true); } |
|
2507 |
if (val <= 0x139f) { RETURN (false); } |
|
2508 |
RETURN (true); |
|
2509 |
||
2510 |
case 0x14: |
|
2511 |
case 0x15: |
|
2512 |
RETURN (true); |
|
2513 |
||
2514 |
case 0x16: |
|
2515 |
if (val == 0x166d) { RETURN (false); } |
|
2516 |
if (val == 0x166e) { RETURN (false); } |
|
2517 |
if (val == 0x1680) { RETURN (false); } |
|
2518 |
if (val == 0x169b) { RETURN (false); } |
|
2519 |
if (val == 0x169c) { RETURN (false); } |
|
2520 |
if (val <= 0x16ea) { RETURN (true); } |
|
2521 |
RETURN (false); |
|
2522 |
||
2523 |
case 0x17: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2524 |
#ifndef UNICODE_3_2 |
9153 | 2525 |
if (val == 0x1712) { RETURN (false); } |
2526 |
if (val == 0x1713) { RETURN (false); } |
|
2527 |
if (val == 0x1714) { RETURN (false); } |
|
2528 |
if (val == 0x1732) { RETURN (false); } |
|
2529 |
if (val == 0x1733) { RETURN (false); } |
|
2530 |
if (val == 0x1734) { RETURN (false); } |
|
2531 |
if (val == 0x1735) { RETURN (false); } |
|
2532 |
if (val == 0x1736) { RETURN (false); } |
|
2533 |
if (val == 0x1752) { RETURN (false); } |
|
2534 |
if (val == 0x1753) { RETURN (false); } |
|
2535 |
if (val == 0x1772) { RETURN (false); } |
|
2536 |
if (val == 0x1773) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2537 |
#endif |
9153 | 2538 |
if (val <= 0x17b3) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2539 |
#ifndef UNICODE_3_2 |
9153 | 2540 |
if (val == 0x17D7) { RETURN (true); } |
2541 |
if (val == 0x17DC) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2542 |
#endif |
9153 | 2543 |
RETURN (false); |
2544 |
||
2545 |
case 0x18: |
|
2546 |
if (val <= 0x181f) { RETURN (false); } |
|
2547 |
if (val <= 0x18a8) { RETURN (true); } |
|
2548 |
RETURN (false); |
|
2549 |
||
2550 |
case 0x19: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2551 |
#ifndef UNICODE_3_2 |
9153 | 2552 |
if (val <= 0x191F) { RETURN (true); } |
2553 |
if (val <= 0x194F) { RETURN (false); } |
|
2554 |
if (val <= 0x197F) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2555 |
#endif |
9153 | 2556 |
RETURN (false); |
2557 |
||
2558 |
case 0x1d: |
|
2559 |
if (val = 0x1d00) { RETURN (true); } |
|
2560 |
RETURN (false); |
|
2561 |
||
2562 |
case 0x1e: |
|
2563 |
RETURN (true); |
|
2564 |
||
2565 |
case 0x1f: |
|
2566 |
if (val <= 0x1fbc) { RETURN (true); } |
|
2567 |
if (val == 0x1fbe) { RETURN (true); } |
|
2568 |
if (val <= 0x1fc1) { RETURN (false); } |
|
2569 |
if (val <= 0x1fcc) { RETURN (true); } |
|
2570 |
if (val <= 0x1fcf) { RETURN (false); } |
|
2571 |
if (val <= 0x1fdc) { RETURN (true); } |
|
2572 |
if (val <= 0x1fdf) { RETURN (false); } |
|
2573 |
if (val <= 0x1fec) { RETURN (true); } |
|
2574 |
if (val <= 0x1ff1) { RETURN (false); } |
|
2575 |
if (val <= 0x1ffc) { RETURN (true); } |
|
2576 |
RETURN (false); |
|
2577 |
||
2578 |
case 0x20: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2579 |
#ifndef UNICODE_3_2 |
9153 | 2580 |
if (val == 0x2071) { RETURN (true); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2581 |
#endif |
9153 | 2582 |
if (val == 0x207f) { RETURN (true); } |
2583 |
RETURN (false); |
|
2584 |
||
2585 |
case 0x21: |
|
2586 |
if (val == 0x2102) { RETURN (true); } |
|
2587 |
if (val == 0x2107) { RETURN (true); } |
|
2588 |
if (val <= 0x2109) { RETURN (false); } |
|
2589 |
if (val <= 0x2113) { RETURN (true); } |
|
2590 |
if (val == 0x2115) { RETURN (true); } |
|
2591 |
if (val <= 0x2118) { RETURN (false); } |
|
2592 |
if (val <= 0x211d) { RETURN (true); } |
|
2593 |
if (val <= 0x2123) { RETURN (false); } |
|
2594 |
if (val == 0x2125) { RETURN (false); } |
|
2595 |
if (val == 0x2127) { RETURN (false); } |
|
2596 |
if (val == 0x2129) { RETURN (false); } |
|
2597 |
if (val == 0x212E) { RETURN (false); } |
|
2598 |
if (val == 0x2132) { RETURN (false); } |
|
2599 |
if (val == 0x213A) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2600 |
#ifndef UNICODE_3_2 |
9153 | 2601 |
if (val == 0x213B) { RETURN (false); } |
2602 |
if (val <= 0x213F) { RETURN (true); } |
|
2603 |
if (val <= 0x2144) { RETURN (false); } |
|
2604 |
if (val == 0x214A) { RETURN (false); } |
|
2605 |
if (val == 0x214B) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2606 |
#endif |
9153 | 2607 |
if (val <= 0x2152) { RETURN (true); } |
2608 |
RETURN (false); |
|
2609 |
||
2610 |
case 0x30: |
|
2611 |
if (val == 0x3005) { RETURN (true); } |
|
2612 |
if (val == 0x3006) { RETURN (true); } |
|
2613 |
if (val <= 0x3030) { RETURN (false); } |
|
2614 |
if (val <= 0x3035) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2615 |
#ifndef UNICODE_3_2 |
9153 | 2616 |
if (val == 0x303B) { RETURN (true); } |
2617 |
if (val == 0x303C) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2618 |
#endif |
9153 | 2619 |
if (val <= 0x3040) { RETURN (false); } |
2620 |
if (val <= 0x3098) { RETURN (true); } |
|
2621 |
if (val <= 0x309c) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2622 |
#ifndef UNICODE_3_2 |
9153 | 2623 |
if (val == 0x30A0) { RETURN (false); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2624 |
#endif |
9153 | 2625 |
if (val == 0x30Fb) { RETURN (false); } |
2626 |
RETURN ((true)); |
|
2627 |
||
2628 |
case 0x31: |
|
2629 |
if (val <= 0x318f) { RETURN (true); } |
|
2630 |
if (val <= 0x319F) { RETURN (false); } |
|
2631 |
RETURN ((true)); |
|
2632 |
||
2633 |
case 0x34: |
|
2634 |
RETURN ((true)); |
|
2635 |
||
2636 |
case 0x4d: |
|
2637 |
if (val <= 0x4DB4) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2638 |
#ifndef UNICODE_3_2 |
9153 | 2639 |
if (val <= 0x4DBF) { RETURN (true); } |
2640 |
RETURN (false); |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2641 |
#else |
9153 | 2642 |
RETURN (true); |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2643 |
#endif |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2644 |
|
9153 | 2645 |
case 0x4e: |
2646 |
RETURN ((true)); |
|
2647 |
||
2648 |
case 0x9f: |
|
2649 |
if (val <= 0x9fa4) { RETURN (false); } |
|
2650 |
RETURN (true); |
|
2651 |
||
2652 |
case 0xA0: |
|
2653 |
case 0xA1: |
|
2654 |
case 0xA2: |
|
2655 |
case 0xA3: |
|
2656 |
RETURN (true); |
|
2657 |
||
2658 |
case 0xA4: |
|
2659 |
if (val <= 0xa48f) { RETURN (true); } |
|
2660 |
RETURN (false); |
|
2661 |
||
2662 |
case 0xA5: |
|
2663 |
RETURN (true); |
|
2664 |
||
2665 |
case 0xAC: |
|
2666 |
RETURN (true); |
|
2667 |
||
2668 |
case 0xD7: |
|
2669 |
RETURN (true); |
|
2670 |
||
2671 |
case 0xF9: |
|
2672 |
case 0xFA: |
|
2673 |
RETURN (true); |
|
2674 |
||
2675 |
case 0xFB: |
|
2676 |
if (val == 0xfb1e) { RETURN (false); } |
|
2677 |
if (val == 0xfb29) { RETURN (false); } |
|
2678 |
RETURN (true); |
|
2679 |
||
2680 |
case 0xFC: |
|
2681 |
RETURN (true); |
|
2682 |
||
2683 |
case 0xFD: |
|
2684 |
if (val <= 0xFD3d) { RETURN (true); } |
|
2685 |
if (val <= 0xFD4F) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2686 |
#ifndef UNICODE_3_2 |
9153 | 2687 |
if (val == 0xFDFC) { RETURN (false); } |
2688 |
if (val == 0xFDFD) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2689 |
#endif |
9153 | 2690 |
RETURN (true); |
2691 |
||
2692 |
case 0xFE: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2693 |
#ifndef UNICODE_3_2 |
9153 | 2694 |
if (val <= 0xFE0F) { RETURN (false); } |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2695 |
#endif |
9153 | 2696 |
if (val <= 0xFE1f) { RETURN (true); } |
2697 |
if (val <= 0xFE6F) { RETURN (false); } |
|
2698 |
if (val <= 0xFEFE) { RETURN (true); } |
|
2699 |
RETURN (false); |
|
2700 |
||
2701 |
case 0xFF: |
|
2702 |
if (val <= 0xFF20) { RETURN (false); } |
|
2703 |
if (val <= 0xFF3a) { RETURN (true); } |
|
2704 |
if (val <= 0xFF40) { RETURN (false); } |
|
2705 |
if (val <= 0xFF5a) { RETURN (true); } |
|
2706 |
if (val <= 0xFF65) { RETURN (false); } |
|
2707 |
if (val <= 0xFFdC) { RETURN (true); } |
|
2708 |
RETURN (false); |
|
2709 |
||
2710 |
case 0x100: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2711 |
#ifndef UNICODE_3_2 |
9153 | 2712 |
RETURN (true); |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2713 |
#else |
9153 | 2714 |
RETURN (false); |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2715 |
#endif |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2716 |
|
9153 | 2717 |
case 0x103: |
2718 |
if (val <= 0x1031f) { RETURN (true); } |
|
2719 |
if (val <= 0x1032F) { RETURN (false); } |
|
2720 |
if (val <= 0x10349) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2721 |
#ifndef UNICODE_3_2 |
9153 | 2722 |
if (val <= 0x1037F) { RETURN (false); } |
2723 |
if (val <= 0x1039E) { RETURN (true); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2724 |
#endif |
9153 | 2725 |
RETURN (false); |
2726 |
||
2727 |
case 0x104: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2728 |
#ifndef UNICODE_3_2 |
9153 | 2729 |
if (val <= 0x1049F) { RETURN (true); } |
2730 |
if (val <= 0x104aF) { RETURN (false); } |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2731 |
#endif |
9153 | 2732 |
RETURN (true); |
2733 |
||
2734 |
case 0x108: |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2735 |
#ifndef UNICODE_3_2 |
9153 | 2736 |
RETURN (true); |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2737 |
#else |
9153 | 2738 |
RETURN (false); |
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2739 |
#endif |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2740 |
|
9153 | 2741 |
case 0x1D4: |
2742 |
case 0x1D5: |
|
2743 |
RETURN (true); |
|
2744 |
||
2745 |
case 0x1D6: |
|
2746 |
if (val == 0x1d6c1) { RETURN (false); } |
|
2747 |
if (val == 0x1d6db) { RETURN (false); } |
|
2748 |
if (val == 0x1d6fb) { RETURN (false); } |
|
2749 |
RETURN (true); |
|
8030
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2750 |
} |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2751 |
RETURN (false); |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2752 |
%} |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2753 |
! ! |
5a4323d0280f
updated to Unicode4.0.0 spec
Claus Gittinger <cg@exept.de>
parents:
8029
diff
changeset
|
2754 |
|
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
2755 |
!Character methodsFor:'tracing'! |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
2756 |
|
4682 | 2757 |
traceInto:aRequestor level:level from:referrer |
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
2758 |
"double dispatch into tracer, passing my type implicitely in the selector" |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
2759 |
|
4682 | 2760 |
^ aRequestor traceCharacter:self level:level from:referrer |
4655
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
2761 |
|
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
2762 |
! ! |
b9405ca0bb4e
added #hasSharedInstances & tracing support
Claus Gittinger <cg@exept.de>
parents:
4340
diff
changeset
|
2763 |
|
8394
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8308
diff
changeset
|
2764 |
!Character methodsFor:'visiting'! |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8308
diff
changeset
|
2765 |
|
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8308
diff
changeset
|
2766 |
acceptVisitor:aVisitor with:aParameter |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8308
diff
changeset
|
2767 |
|
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8308
diff
changeset
|
2768 |
^ aVisitor visitCharacter:self with:aParameter |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8308
diff
changeset
|
2769 |
! ! |
da194de43766
Generalize visitor pattern and define #visit...:with: -methods instead
Stefan Vogel <sv@exept.de>
parents:
8308
diff
changeset
|
2770 |
|
2124 | 2771 |
!Character class methodsFor:'documentation'! |
699 | 2772 |
|
2773 |
version |
|
11956 | 2774 |
^ '$Header: /cvs/stx/stx/libbasic/Character.st,v 1.139 2009-09-16 19:22:24 cg Exp $' |
699 | 2775 |
! ! |