197 self encoderFor:#'jis7' |
197 self encoderFor:#'jis7' |
198 self encoderFor:#'utf8' |
198 self encoderFor:#'utf8' |
199 " |
199 " |
200 ! |
200 ! |
201 |
201 |
202 encoderFor:encodingNameSymbol ifAbsent:exceptionValue |
202 encoderFor:encodingNameSymbolArg ifAbsent:exceptionValue |
203 "given the name of an encoding, return an encoder-instance which can map these from/into unicode." |
203 "given the name of an encoding, return an encoder-instance which can map these from/into unicode." |
204 |
204 |
205 |enc clsName cls lcName name unicodeEncoders unicodeEncoderClasses| |
205 |encodingNameSymbol enc clsName cls lcName name unicodeEncoders unicodeEncoderClasses| |
206 |
206 |
|
207 encodingNameSymbol := encodingNameSymbolArg. |
207 encodingNameSymbol isNil ifTrue:[ ^ NullEncoderInstance]. |
208 encodingNameSymbol isNil ifTrue:[ ^ NullEncoderInstance]. |
|
209 |
|
210 encodingNameSymbol == #'iso10646-1' ifTrue:[ encodingNameSymbol := #'unicode']. |
|
211 encodingNameSymbol isSymbol ifFalse:[self halt:'symbol argument expected'. encodingNameSymbol := encodingNameSymbol asSymbol]. |
208 |
212 |
209 lcName := encodingNameSymbol asLowercase. |
213 lcName := encodingNameSymbol asLowercase. |
210 name := lcName asSymbolIfInterned. |
214 name := lcName asSymbolIfInterned. |
211 name isNil ifTrue:[name := lcName]. |
215 name isNil ifTrue:[name := lcName]. |
212 |
216 |
788 superSetEncoding := superSetEncodingArg asLowercase. |
792 superSetEncoding := superSetEncodingArg asLowercase. |
789 |
793 |
790 (subSetEncoding match:superSetEncoding) ifTrue:[^ true]. |
794 (subSetEncoding match:superSetEncoding) ifTrue:[^ true]. |
791 |
795 |
792 (('iso10646*' match:superSetEncoding) or:[superSetEncoding = 'unicode']) ifTrue:[ |
796 (('iso10646*' match:superSetEncoding) or:[superSetEncoding = 'unicode']) ifTrue:[ |
793 ('ascii*' match:subSetEncoding) ifTrue:[^ true]. |
797 ('ms-*' match:subSetEncoding) ifTrue:[^ true]. |
794 ('iso8859*' match:subSetEncoding) ifTrue:[^ true]. |
798 ('ascii*' match:subSetEncoding) ifTrue:[^ true]. |
795 ('jis*' match:subSetEncoding) ifTrue:[^ true]. |
799 ('iso8859*' match:subSetEncoding) ifTrue:[^ true]. |
796 ('koi8*' match:subSetEncoding) ifTrue:[^ true]. |
800 ('jis*' match:subSetEncoding) ifTrue:[^ true]. |
797 ('ksc*' match:subSetEncoding) ifTrue:[^ true]. |
801 ('koi8*' match:subSetEncoding) ifTrue:[^ true]. |
798 ('big*' match:subSetEncoding) ifTrue:[^ true]. |
802 ('ksc*' match:subSetEncoding) ifTrue:[^ true]. |
799 ('cns*' match:subSetEncoding) ifTrue:[^ true]. |
803 ('big*' match:subSetEncoding) ifTrue:[^ true]. |
800 ('gb2312*' match:subSetEncoding) ifTrue:[^ true]. |
804 ('cns*' match:subSetEncoding) ifTrue:[^ true]. |
|
805 ('gb2312*' match:subSetEncoding) ifTrue:[^ true]. |
801 ]. |
806 ]. |
802 |
807 |
803 "/ if the subSet is iso8859-*, that means ascii (i.e. the lower 7 bits of iso8859 only). |
808 "/ if the subSet is iso8859-*, that means ascii (i.e. the lower 7 bits of iso8859 only). |
804 ((subSetEncoding = 'iso8859*') or:[subSetEncoding = 'iso8859-*']) ifTrue:[ |
809 ((subSetEncoding = 'iso8859*') or:[subSetEncoding = 'iso8859-*']) ifTrue:[ |
805 ('ascii*' match:superSetEncoding) ifTrue:[^ true]. |
810 ('ascii*' match:superSetEncoding) ifTrue:[^ true]. |
|
811 ('ms-ansi*' match:superSetEncoding) ifTrue:[^ true]. |
806 ]. |
812 ]. |
807 (subSetEncoding = 'ascii') ifTrue:[ |
813 (subSetEncoding = 'ascii') ifTrue:[ |
808 ('iso8859*' match:superSetEncoding) ifTrue:[^ true]. |
814 ('iso8859*' match:superSetEncoding) ifTrue:[^ true]. |
|
815 ('ms-ansi*' match:superSetEncoding) ifTrue:[^ true]. |
809 ]. |
816 ]. |
810 |
817 |
811 "/ TODO: check the charSets mappingTables... |
818 "/ TODO: check the charSets mappingTables... |
812 "/ self halt. |
819 "/ self halt. |
813 ^ false. |
820 ^ false. |