equal
deleted
inserted
replaced
|
1 "{ Encoding: utf8 }" |
|
2 |
1 " |
3 " |
2 COPYRIGHT (c) 2004 by eXept Software AG |
4 COPYRIGHT (c) 2004 by eXept Software AG |
3 All Rights Reserved |
5 All Rights Reserved |
4 |
6 |
5 This software is furnished under a license and may be used |
7 This software is furnished under a license and may be used |
7 inclusion of the above copyright notice. This software may not |
9 inclusion of the above copyright notice. This software may not |
8 be provided or otherwise made available to, or used by, any |
10 be provided or otherwise made available to, or used by, any |
9 other person. No title to or ownership of the software is |
11 other person. No title to or ownership of the software is |
10 hereby transferred. |
12 hereby transferred. |
11 " |
13 " |
12 |
|
13 "{ Package: 'stx:libbasic' }" |
14 "{ Package: 'stx:libbasic' }" |
14 |
15 |
15 "{ NameSpace: CharacterEncoderImplementations }" |
16 "{ NameSpace: CharacterEncoderImplementations }" |
16 |
17 |
17 TwoByteEncoder subclass:#JIS0208_to_JIS7 |
18 VariableBytesEncoder subclass:#JIS0208_to_JIS7 |
18 instanceVariableNames:'' |
19 instanceVariableNames:'' |
19 classVariableNames:'Jis7KanjiEscapeSequence Jis7RomanEscapeSequence |
20 classVariableNames:'Jis7KanjiEscapeSequence Jis7RomanEscapeSequence |
20 JisISO2022EscapeSequence Jis7KanjiOldEscapeSequence' |
21 JisISO2022EscapeSequence Jis7KanjiOldEscapeSequence' |
21 poolDictionaries:'' |
22 poolDictionaries:'' |
22 category:'Collections-Text-Encodings' |
23 category:'Collections-Text-Encodings' |
36 other person. No title to or ownership of the software is |
37 other person. No title to or ownership of the software is |
37 hereby transferred. |
38 hereby transferred. |
38 " |
39 " |
39 ! |
40 ! |
40 |
41 |
|
42 documentation |
|
43 " |
|
44 documentation to be added. |
|
45 |
|
46 [author:] |
|
47 stefan |
|
48 |
|
49 [instance variables:] |
|
50 |
|
51 [class variables:] |
|
52 |
|
53 [see also:] |
|
54 |
|
55 " |
|
56 ! |
|
57 |
41 examples |
58 examples |
42 " |
59 " |
43 Encoding (jis0208 to jis-7) |
60 Encoding (jis0208 to jis-7) |
44 |t| |
61 |t| |
45 |
62 |
142 |
159 |
143 ^ #'jis0208' |
160 ^ #'jis0208' |
144 ! ! |
161 ! ! |
145 |
162 |
146 !JIS0208_to_JIS7 methodsFor:'encoding & decoding'! |
163 !JIS0208_to_JIS7 methodsFor:'encoding & decoding'! |
147 |
|
148 decode:aCode |
|
149 self shouldNotImplement "/ no single byte conversion possible |
|
150 ! |
|
151 |
164 |
152 decodeString:aString |
165 decodeString:aString |
153 "given a string in JIS7 encoding, |
166 "given a string in JIS7 encoding, |
154 return a new string containing the same characters, in JIS0208 encoding. |
167 return a new string containing the same characters, in JIS0208 encoding. |
155 The argument is interpreted as a JIS7 or ISO2022-JP encoded singleByte string. |
168 The argument is interpreted as a JIS7 or ISO2022-JP encoded singleByte string. |
236 ] ifFalse:[ |
249 ] ifFalse:[ |
237 (n2 == $( and:[n3 == $I ]) ifTrue:[ |
250 (n2 == $( and:[n3 == $I ]) ifTrue:[ |
238 singleBytes := true. |
251 singleBytes := true. |
239 katakana := true. |
252 katakana := true. |
240 ] ifFalse:[ |
253 ] ifFalse:[ |
241 singleBytes ifTrue:[ |
254 singleBytes ifFalse:[ |
242 newString at:dstIdx put:n1. |
|
243 newString at:(dstIdx + 1) put:n2. |
|
244 newString at:(dstIdx + 2) put:n3. |
|
245 dstIdx := dstIdx + 3. |
|
246 ] ifFalse:[ |
|
247 DecodingError |
255 DecodingError |
248 raiseWith:aString |
256 raiseRequestWith:aString |
249 errorString:'JIS7 decoding failed (not JIS7 encoded ?)'. |
257 errorString:'JIS7 decoding failed (not JIS7 encoded ?)'. |
250 newString at:dstIdx put:n1. |
258 ]. |
251 newString at:(dstIdx + 1) put:n2. |
259 newString at:dstIdx put:n1. |
252 newString at:(dstIdx + 2) put:n3. |
260 newString at:(dstIdx + 1) put:n2. |
253 dstIdx := dstIdx + 3. |
261 newString at:(dstIdx + 2) put:n3. |
254 ] |
262 dstIdx := dstIdx + 3. |
255 ] |
263 ] |
256 ] |
264 ] |
257 ] |
265 ] |
258 ] |
266 ] |
259 ]. |
267 ]. |
262 ^ newString copyFrom:1 to:dstIdx-1. |
270 ^ newString copyFrom:1 to:dstIdx-1. |
263 ] |
271 ] |
264 ] |
272 ] |
265 ]. |
273 ]. |
266 ^ newString |
274 ^ newString |
267 ! |
275 |
268 |
276 "Modified (format): / 17-01-2018 / 17:20:52 / stefan" |
269 encode:aCode |
|
270 self shouldNotImplement "/ no single byte conversion possible |
|
271 ! |
277 ! |
272 |
278 |
273 encodeString:aJISString |
279 encodeString:aJISString |
274 "return a new string with aJISStrings characters as JIS7 encoded 7bit string, |
280 "return a new string with aJISStrings characters as JIS7 encoded 7bit string, |
275 The receiver must be a JIS encoded character string. |
281 The receiver must be a JIS encoded character string. |
370 ! ! |
376 ! ! |
371 |
377 |
372 !JIS0208_to_JIS7 class methodsFor:'documentation'! |
378 !JIS0208_to_JIS7 class methodsFor:'documentation'! |
373 |
379 |
374 version |
380 version |
375 ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__JIS0208_to_JIS7.st,v 1.7 2004-03-12 09:15:11 ca Exp $' |
381 ^ '$Header$' |
376 ! ! |
382 ! ! |
|
383 |