CharacterEncoder.st
changeset 14209 912e4845d386
parent 14207 f80306416305
child 14523 91746a24d5ad
--- a/CharacterEncoder.st	Thu Jul 12 20:07:54 2012 +0200
+++ b/CharacterEncoder.st	Fri Jul 13 14:46:09 2012 +0200
@@ -1,6 +1,6 @@
 "
  COPYRIGHT (c) 2004 by eXept Software AG
-	      All Rights Reserved
+              All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -12,55 +12,55 @@
 "{ Package: 'stx:libbasic' }"
 
 Object subclass:#CharacterEncoder
-	instanceVariableNames:''
-	classVariableNames:'EncoderClassesByName EncodersByName CachedEncoders LastEncoder
-		AccessLock NullEncoderInstance Jis7KanjiEscapeSequence
-		Jis7RomanEscapeSequence JisISO2022EscapeSequence
-		Jis7KanjiOldEscapeSequence'
-	poolDictionaries:''
-	category:'Collections-Text-Encodings'
+        instanceVariableNames:''
+        classVariableNames:'EncoderClassesByName EncodersByName CachedEncoders LastEncoder
+                AccessLock NullEncoderInstance Jis7KanjiEscapeSequence
+                Jis7RomanEscapeSequence JisISO2022EscapeSequence
+                Jis7KanjiOldEscapeSequence'
+        poolDictionaries:''
+        category:'Collections-Text-Encodings'
 !
 
 CharacterEncoder subclass:#CompoundEncoder
-	instanceVariableNames:'decoder encoder'
-	classVariableNames:''
-	poolDictionaries:''
-	privateIn:CharacterEncoder
+        instanceVariableNames:'decoder encoder'
+        classVariableNames:''
+        poolDictionaries:''
+        privateIn:CharacterEncoder
 !
 
 CharacterEncoder subclass:#DefaultEncoder
-	instanceVariableNames:''
-	classVariableNames:''
-	poolDictionaries:''
-	privateIn:CharacterEncoder
+        instanceVariableNames:''
+        classVariableNames:''
+        poolDictionaries:''
+        privateIn:CharacterEncoder
 !
 
 CharacterEncoder subclass:#InverseEncoder
-	instanceVariableNames:'decoder'
-	classVariableNames:''
-	poolDictionaries:''
-	privateIn:CharacterEncoder
+        instanceVariableNames:'decoder'
+        classVariableNames:''
+        poolDictionaries:''
+        privateIn:CharacterEncoder
 !
 
 CharacterEncoder subclass:#NullEncoder
-	instanceVariableNames:''
-	classVariableNames:''
-	poolDictionaries:''
-	privateIn:CharacterEncoder
+        instanceVariableNames:''
+        classVariableNames:''
+        poolDictionaries:''
+        privateIn:CharacterEncoder
 !
 
 CharacterEncoder subclass:#OtherEncoding
-	instanceVariableNames:''
-	classVariableNames:''
-	poolDictionaries:''
-	privateIn:CharacterEncoder
+        instanceVariableNames:''
+        classVariableNames:''
+        poolDictionaries:''
+        privateIn:CharacterEncoder
 !
 
 CharacterEncoder subclass:#TwoStepEncoder
-	instanceVariableNames:'encoder1 encoder2'
-	classVariableNames:''
-	poolDictionaries:''
-	privateIn:CharacterEncoder
+        instanceVariableNames:'encoder1 encoder2'
+        classVariableNames:''
+        poolDictionaries:''
+        privateIn:CharacterEncoder
 !
 
 !CharacterEncoder class methodsFor:'documentation'!
@@ -68,7 +68,7 @@
 copyright
 "
  COPYRIGHT (c) 2004 by eXept Software AG
-	      All Rights Reserved
+              All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -720,7 +720,7 @@
      This happens to be the same as ISO2022-JP's escape sequence."
 
     Jis7KanjiEscapeSequence isNil ifTrue:[
-	Jis7KanjiEscapeSequence := Character esc asString , '$B'.
+        Jis7KanjiEscapeSequence := Character esc asString , '$B'.
     ].
     ^ Jis7KanjiEscapeSequence.
 
@@ -741,7 +741,7 @@
     "return the escape sequence used to switch to roman in jis7 encoded strings"
 
     Jis7RomanEscapeSequence isNil ifTrue:[
-	Jis7RomanEscapeSequence := Character esc asString , '(J'.
+        Jis7RomanEscapeSequence := Character esc asString , '(J'.
     ].
     ^ Jis7RomanEscapeSequence.
 
@@ -753,7 +753,7 @@
     "return the escape sequence used to switch to kanji in iso2022 encoded strings"
 
     JisISO2022EscapeSequence isNil ifTrue:[
-	JisISO2022EscapeSequence := Character esc asString , '&@' , Character esc asString , '$B'.
+        JisISO2022EscapeSequence := Character esc asString , '&@' , Character esc asString , '$B'.
     ].
     ^ JisISO2022EscapeSequence.
 ! !
@@ -781,8 +781,8 @@
      ISO8859_1 encodeString:(ISO8859_1 decodeString:'hello') 
 
      ISO8859_5 decodeString:(String 
-				with:(Character value:16rE4)
-				with:(Character value:16rE0)) 
+                                with:(Character value:16rE4)
+                                with:(Character value:16rE0)) 
     "
 !
 
@@ -797,18 +797,18 @@
     oldEncoding == newEncoding ifTrue:[^ codePoint].
 
     oldEncoding == #'unicode' ifTrue:[
-	newEncoding == #'iso8859-1' ifTrue:[
-	    codePoint <= 16rFF ifTrue:[
-		^ codePoint
-	    ]
-	]
+        newEncoding == #'iso8859-1' ifTrue:[
+            codePoint <= 16rFF ifTrue:[
+                ^ codePoint
+            ]
+        ]
     ].
     newEncoding == #'unicode' ifTrue:[
-	oldEncoding == #'iso8859-1' ifTrue:[
-	    codePoint <= 16rFF ifTrue:[
-		^ codePoint
-	    ]
-	]
+        oldEncoding == #'iso8859-1' ifTrue:[
+            codePoint <= 16rFF ifTrue:[
+                ^ codePoint
+            ]
+        ]
     ].
     encoder := self encoderToEncodeFrom:oldEncoding into:newEncoding.
     ^ encoder encode:codePoint.
@@ -835,18 +835,18 @@
     oldEncoding == newEncoding ifTrue:[^ aString].
 
     oldEncoding == #'unicode' ifTrue:[
-	newEncoding == #'iso8859-1' ifTrue:[
-	    aString bitsPerCharacter == 8 ifTrue:[
-		^ aString
-	    ]
-	]
+        newEncoding == #'iso8859-1' ifTrue:[
+            aString bitsPerCharacter == 8 ifTrue:[
+                ^ aString
+            ]
+        ]
     ].
     newEncoding == #'unicode' ifTrue:[
-	oldEncoding == #'iso8859-1' ifTrue:[
-	    aString bitsPerCharacter == 8 ifTrue:[
-		^ aString
-	    ]
-	]
+        oldEncoding == #'iso8859-1' ifTrue:[
+            aString bitsPerCharacter == 8 ifTrue:[
+                ^ aString
+            ]
+        ]
     ].
 
     encoder := self encoderToEncodeFrom:oldEncoding into:newEncoding.
@@ -870,10 +870,10 @@
     self initialize.
 
     self isAbstract ifFalse:[
-	(self mapFileURL1_relativePathName notNil
-	or:[ self mapFileURL2_relativePathName notNil]) ifTrue:[
-	    self class removeSelector:#mapping.
-	].
+        (self mapFileURL1_relativePathName notNil
+        or:[ self mapFileURL2_relativePathName notNil]) ifTrue:[
+            self class removeSelector:#mapping.
+        ].
     ].
 
     "
@@ -914,7 +914,7 @@
 
     rel := self mapFileURL1_relativePathName.
     rel isNil ifTrue:[
-	^ nil
+        ^ nil
     ].
     ^ 'http://www.unicode.org/Public/MAPPINGS/' , rel
 !
@@ -926,7 +926,7 @@
 
     rel := self mapFileURL2_relativePathName.
     rel isNil ifTrue:[
-	^ nil
+        ^ nil
     ].
     ^ 'http://std.dkuug.dk/i18n/charmaps/' , rel
 ! !
@@ -1349,23 +1349,25 @@
 
     sender := thisContext sender.
     ((sender selector == #encode:) or:[sender selector == #decode:]) ifFalse:[
-	badCodePoint := sender methodHome argAt:1
+        badCodePoint := sender methodHome argAt:1
     ].
     ^ (EncodingError new)
-	defaultValue:(self defaultEncoderValue);
-	parameter:badCodePoint;
-	messageText:'unrepresentable unicode'; 
-	suspendedContext:sender;
-	raiseRequest
+        defaultValue:(self defaultEncoderValue);
+        parameter:badCodePoint;
+        messageText:'unrepresentable code (some character cannot be represented)'; 
+        suspendedContext:sender;
+        raiseRequest
+
+    "Modified: / 12-07-2012 / 20:36:37 / cg"
 ! !
 
 !CharacterEncoder methodsFor:'printing'!
 
 printOn:aStream
     aStream 
-	nextPutAll:(self nameOfDecodedCode);
-	nextPutAll:'->';
-	nextPutAll:(self nameOfEncoding)
+        nextPutAll:(self nameOfDecodedCode);
+        nextPutAll:'->';
+        nextPutAll:(self nameOfEncoding)
 ! !
 
 !CharacterEncoder methodsFor:'private'!
@@ -1434,9 +1436,9 @@
 "
     A compoundEncoder uses two real encoders;
     to encode:
-	string -> decoder(encode) -> encoder -> result
+        string -> decoder(encode) -> encoder -> result
     to decode:
-	string -> encoder -> decoder -> result
+        string -> encoder -> decoder -> result
 
     |e|
 
@@ -1478,8 +1480,8 @@
 
 printOn:aStream
     aStream 
-	nextPutAll:(decoder nameOfEncoding);
-	nextPutAll:'->'.
+        nextPutAll:(decoder nameOfEncoding);
+        nextPutAll:'->'.
 "/        nextPutAll:(decoder nameOfDecodedCode);
 "/        nextPutAll:'->';
 "/        nextPutAll:(encoder nameOfEncoding)
@@ -1531,9 +1533,9 @@
 
 printOn:aStream
     aStream 
-	nextPutAll:(decoder nameOfEncoding);
-	nextPutAll:'->';
-	nextPutAll:(decoder nameOfDecodedCode)
+        nextPutAll:(decoder nameOfEncoding);
+        nextPutAll:'->';
+        nextPutAll:(decoder nameOfDecodedCode)
 ! !
 
 !CharacterEncoder::InverseEncoder methodsFor:'queries'!
@@ -1594,9 +1596,9 @@
 "
     A twoStepEncoder uses two real encoders;
     to encode:
-	string -> encoder1(encode) -> encoder2(encode) -> result
+        string -> encoder1(encode) -> encoder2(encode) -> result
     to decode:
-	string -> encoder2(decode) -> encoder1(decode) -> result
+        string -> encoder2(decode) -> encoder1(decode) -> result
 "
 ! !
 
@@ -1631,11 +1633,11 @@
 
 printOn:aStream
     aStream 
-	nextPutAll:(encoder1 nameOfDecodedCode);
-	nextPutAll:'->';
-	nextPutAll:(encoder1 nameOfEncoding);
-	nextPutAll:'->';
-	nextPutAll:(encoder2 nameOfEncoding)
+        nextPutAll:(encoder1 nameOfDecodedCode);
+        nextPutAll:'->';
+        nextPutAll:(encoder1 nameOfEncoding);
+        nextPutAll:'->';
+        nextPutAll:(encoder2 nameOfEncoding)
 ! !
 
 !CharacterEncoder::TwoStepEncoder methodsFor:'queries'!
@@ -1663,11 +1665,11 @@
 !CharacterEncoder class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoder.st,v 1.117 2012-07-12 17:46:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoder.st,v 1.118 2012-07-13 12:46:09 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoder.st,v 1.117 2012-07-12 17:46:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoder.st,v 1.118 2012-07-13 12:46:09 cg Exp $'
 ! !
 
 CharacterEncoder initialize!