# HG changeset patch # User Stefan Vogel # Date 1078523858 -3600 # Node ID 794d8e3f11d876c3789612a84ea93046d53a843b # Parent e0537422e2d38ae165b029b7a0a4c339e5a751ec Use the ANSI-blessed #codePoint instead of deprecated #asciiValue diff -r e0537422e2d3 -r 794d8e3f11d8 CharacterEncoderImplementations__ISO10646_to_UTF8.st --- a/CharacterEncoderImplementations__ISO10646_to_UTF8.st Fri Mar 05 22:51:48 2004 +0100 +++ b/CharacterEncoderImplementations__ISO10646_to_UTF8.st Fri Mar 05 22:57:38 2004 +0100 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - "{ Package: 'stx:libbasic' }" "{ NameSpace: CharacterEncoderImplementations }" @@ -286,7 +284,7 @@ aUnicodeString do:[:eachCharacter | |codePoint b1 b2 b3 b4 b5 v "{Class: SmallInteger }"| - codePoint := eachCharacter asciiValue. + codePoint := eachCharacter codePoint. codePoint <= 16r7F ifTrue:[ s nextPut:eachCharacter. ] ifFalse:[ @@ -355,5 +353,5 @@ !ISO10646_to_UTF8 class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__ISO10646_to_UTF8.st,v 1.1 2004-03-05 17:18:03 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__ISO10646_to_UTF8.st,v 1.2 2004-03-05 21:57:28 stefan Exp $' ! ! diff -r e0537422e2d3 -r 794d8e3f11d8 CharacterEncoderImplementations__JIS0208_to_JIS7.st --- a/CharacterEncoderImplementations__JIS0208_to_JIS7.st Fri Mar 05 22:51:48 2004 +0100 +++ b/CharacterEncoderImplementations__JIS0208_to_JIS7.st Fri Mar 05 22:57:38 2004 +0100 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - "{ Package: 'stx:libbasic' }" "{ NameSpace: CharacterEncoderImplementations }" @@ -126,15 +124,6 @@ "Modified: 30.6.1997 / 16:03:16 / cg" ! -jis7KanjiOldEscapeSequence - "return the escape sequence used to switch to kanji in some old jis7 encoded strings." - - Jis7KanjiOldEscapeSequence isNil ifTrue:[ - Jis7KanjiOldEscapeSequence := Character esc asString , '$@'.. - ]. - ^ Jis7KanjiOldEscapeSequence. -! - jis7RomanEscapeSequence "return the escape sequence used to switch to roman in jis7 encoded strings" @@ -232,8 +221,8 @@ ]. ] ifFalse:[ start to:(stop - 2) by:2 do:[:i | - b1 := (aString at:i) asciiValue. - b2 := (aString at:i+1) asciiValue. + b1 := (aString at:i) codePoint. + b2 := (aString at:i+1) codePoint. val := (b1 bitShift:8) bitOr:b2. newString at:dstIdx put:(Character value:val). dstIdx := dstIdx + 1. @@ -328,65 +317,65 @@ out := WriteStream on:(String new:(sz * 2)). 1 to:sz do:[:srcIndex | - c := aJISString at:srcIndex. - b1 := c asciiValue. - b1 < 33 ifTrue:[ - "/ a control character - inSingleByteMode ifFalse:[ - out nextPutAll:roman. - inSingleByteMode := true - ]. - out nextPut:c. - ] ifFalse:[ - "/ check for a roman character - "/ the two numbers below are romanTable min and romanTable max - (b1 between:16r2121 and:16r2573) ifTrue:[ - val := romans indexOf:b1. - val2 := val - 1 + 32. - (val ~~ 0 and:[val2 <= 16r7F]) ifTrue:[ - inSingleByteMode ifFalse:[ - out nextPutAll:roman. - inSingleByteMode := true - ]. - out nextPut:(Character value:val2) - ] ifFalse:[ - inSingleByteMode ifTrue:[ - out nextPutAll:kanji. - inSingleByteMode := false - ]. - out nextPut:(Character value:(b1 bitShift:-8)). - out nextPut:(Character value:(b1 bitAnd:16rFF)). - ]. - ] ifFalse:[ - b1 <= 255 ifTrue:[ - "/ mhmh - unrepresentable roman (national chars) + c := aJISString at:srcIndex. + b1 := c codePoint. + b1 < 33 ifTrue:[ + "/ a control character + inSingleByteMode ifFalse:[ + out nextPutAll:roman. + inSingleByteMode := true + ]. + out nextPut:c. + ] ifFalse:[ + "/ check for a roman character + "/ the two numbers below are romanTable min and romanTable max + (b1 between:16r2121 and:16r2573) ifTrue:[ + val := romans indexOf:b1. + val2 := val - 1 + 32. + (val ~~ 0 and:[val2 <= 16r7F]) ifTrue:[ + inSingleByteMode ifFalse:[ + out nextPutAll:roman. + inSingleByteMode := true + ]. + out nextPut:(Character value:val2) + ] ifFalse:[ + inSingleByteMode ifTrue:[ + out nextPutAll:kanji. + inSingleByteMode := false + ]. + out nextPut:(Character value:(b1 bitShift:-8)). + out nextPut:(Character value:(b1 bitAnd:16rFF)). + ]. + ] ifFalse:[ + b1 <= 255 ifTrue:[ + "/ mhmh - unrepresentable roman (national chars) "/ b1 >= 160 ifTrue:[ "/ ('no rep for ' , b1 printString) printNL. "/ ]. - "/ there are non-japanese characters in there... - "/ assume that is OK (leave as is) ... + "/ there are non-japanese characters in there... + "/ assume that is OK (leave as is) ... "/ EncodingFailedError "/ raiseWith:aJISString "/ errorString:'JIS7 encoding failed (contains 8-bit characters ?)'. - inSingleByteMode ifFalse:[ - out nextPutAll:roman. - inSingleByteMode := true - ]. - out nextPut:c - ] ifFalse:[ - inSingleByteMode ifTrue:[ - out nextPutAll:kanji. - inSingleByteMode := false - ]. - out nextPut:(Character value:(b1 bitShift:-8)). - out nextPut:(Character value:(b1 bitAnd:16rFF)). - ] - ] - ]. + inSingleByteMode ifFalse:[ + out nextPutAll:roman. + inSingleByteMode := true + ]. + out nextPut:c + ] ifFalse:[ + inSingleByteMode ifTrue:[ + out nextPutAll:kanji. + inSingleByteMode := false + ]. + out nextPut:(Character value:(b1 bitShift:-8)). + out nextPut:(Character value:(b1 bitAnd:16rFF)). + ] + ] + ]. ]. inSingleByteMode ifFalse:[ - out nextPutAll:roman. + out nextPutAll:roman. ]. ^ out contents @@ -399,5 +388,5 @@ !JIS0208_to_JIS7 class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__JIS0208_to_JIS7.st,v 1.1 2004-03-05 17:27:22 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__JIS0208_to_JIS7.st,v 1.2 2004-03-05 21:57:38 stefan Exp $' ! ! diff -r e0537422e2d3 -r 794d8e3f11d8 Encoder_ISO10646_to_UTF8.st --- a/Encoder_ISO10646_to_UTF8.st Fri Mar 05 22:51:48 2004 +0100 +++ b/Encoder_ISO10646_to_UTF8.st Fri Mar 05 22:57:38 2004 +0100 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - "{ Package: 'stx:libbasic' }" "{ NameSpace: CharacterEncoderImplementations }" @@ -286,7 +284,7 @@ aUnicodeString do:[:eachCharacter | |codePoint b1 b2 b3 b4 b5 v "{Class: SmallInteger }"| - codePoint := eachCharacter asciiValue. + codePoint := eachCharacter codePoint. codePoint <= 16r7F ifTrue:[ s nextPut:eachCharacter. ] ifFalse:[ @@ -355,5 +353,5 @@ !ISO10646_to_UTF8 class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Attic/Encoder_ISO10646_to_UTF8.st,v 1.1 2004-03-05 17:18:03 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Attic/Encoder_ISO10646_to_UTF8.st,v 1.2 2004-03-05 21:57:28 stefan Exp $' ! ! diff -r e0537422e2d3 -r 794d8e3f11d8 Encoder_JIS0208_to_JIS7.st --- a/Encoder_JIS0208_to_JIS7.st Fri Mar 05 22:51:48 2004 +0100 +++ b/Encoder_JIS0208_to_JIS7.st Fri Mar 05 22:57:38 2004 +0100 @@ -1,5 +1,3 @@ -"{ Encoding: utf8 }" - "{ Package: 'stx:libbasic' }" "{ NameSpace: CharacterEncoderImplementations }" @@ -126,15 +124,6 @@ "Modified: 30.6.1997 / 16:03:16 / cg" ! -jis7KanjiOldEscapeSequence - "return the escape sequence used to switch to kanji in some old jis7 encoded strings." - - Jis7KanjiOldEscapeSequence isNil ifTrue:[ - Jis7KanjiOldEscapeSequence := Character esc asString , '$@'.. - ]. - ^ Jis7KanjiOldEscapeSequence. -! - jis7RomanEscapeSequence "return the escape sequence used to switch to roman in jis7 encoded strings" @@ -232,8 +221,8 @@ ]. ] ifFalse:[ start to:(stop - 2) by:2 do:[:i | - b1 := (aString at:i) asciiValue. - b2 := (aString at:i+1) asciiValue. + b1 := (aString at:i) codePoint. + b2 := (aString at:i+1) codePoint. val := (b1 bitShift:8) bitOr:b2. newString at:dstIdx put:(Character value:val). dstIdx := dstIdx + 1. @@ -328,65 +317,65 @@ out := WriteStream on:(String new:(sz * 2)). 1 to:sz do:[:srcIndex | - c := aJISString at:srcIndex. - b1 := c asciiValue. - b1 < 33 ifTrue:[ - "/ a control character - inSingleByteMode ifFalse:[ - out nextPutAll:roman. - inSingleByteMode := true - ]. - out nextPut:c. - ] ifFalse:[ - "/ check for a roman character - "/ the two numbers below are romanTable min and romanTable max - (b1 between:16r2121 and:16r2573) ifTrue:[ - val := romans indexOf:b1. - val2 := val - 1 + 32. - (val ~~ 0 and:[val2 <= 16r7F]) ifTrue:[ - inSingleByteMode ifFalse:[ - out nextPutAll:roman. - inSingleByteMode := true - ]. - out nextPut:(Character value:val2) - ] ifFalse:[ - inSingleByteMode ifTrue:[ - out nextPutAll:kanji. - inSingleByteMode := false - ]. - out nextPut:(Character value:(b1 bitShift:-8)). - out nextPut:(Character value:(b1 bitAnd:16rFF)). - ]. - ] ifFalse:[ - b1 <= 255 ifTrue:[ - "/ mhmh - unrepresentable roman (national chars) + c := aJISString at:srcIndex. + b1 := c codePoint. + b1 < 33 ifTrue:[ + "/ a control character + inSingleByteMode ifFalse:[ + out nextPutAll:roman. + inSingleByteMode := true + ]. + out nextPut:c. + ] ifFalse:[ + "/ check for a roman character + "/ the two numbers below are romanTable min and romanTable max + (b1 between:16r2121 and:16r2573) ifTrue:[ + val := romans indexOf:b1. + val2 := val - 1 + 32. + (val ~~ 0 and:[val2 <= 16r7F]) ifTrue:[ + inSingleByteMode ifFalse:[ + out nextPutAll:roman. + inSingleByteMode := true + ]. + out nextPut:(Character value:val2) + ] ifFalse:[ + inSingleByteMode ifTrue:[ + out nextPutAll:kanji. + inSingleByteMode := false + ]. + out nextPut:(Character value:(b1 bitShift:-8)). + out nextPut:(Character value:(b1 bitAnd:16rFF)). + ]. + ] ifFalse:[ + b1 <= 255 ifTrue:[ + "/ mhmh - unrepresentable roman (national chars) "/ b1 >= 160 ifTrue:[ "/ ('no rep for ' , b1 printString) printNL. "/ ]. - "/ there are non-japanese characters in there... - "/ assume that is OK (leave as is) ... + "/ there are non-japanese characters in there... + "/ assume that is OK (leave as is) ... "/ EncodingFailedError "/ raiseWith:aJISString "/ errorString:'JIS7 encoding failed (contains 8-bit characters ?)'. - inSingleByteMode ifFalse:[ - out nextPutAll:roman. - inSingleByteMode := true - ]. - out nextPut:c - ] ifFalse:[ - inSingleByteMode ifTrue:[ - out nextPutAll:kanji. - inSingleByteMode := false - ]. - out nextPut:(Character value:(b1 bitShift:-8)). - out nextPut:(Character value:(b1 bitAnd:16rFF)). - ] - ] - ]. + inSingleByteMode ifFalse:[ + out nextPutAll:roman. + inSingleByteMode := true + ]. + out nextPut:c + ] ifFalse:[ + inSingleByteMode ifTrue:[ + out nextPutAll:kanji. + inSingleByteMode := false + ]. + out nextPut:(Character value:(b1 bitShift:-8)). + out nextPut:(Character value:(b1 bitAnd:16rFF)). + ] + ] + ]. ]. inSingleByteMode ifFalse:[ - out nextPutAll:roman. + out nextPutAll:roman. ]. ^ out contents @@ -399,5 +388,5 @@ !JIS0208_to_JIS7 class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Attic/Encoder_JIS0208_to_JIS7.st,v 1.1 2004-03-05 17:27:22 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Attic/Encoder_JIS0208_to_JIS7.st,v 1.2 2004-03-05 21:57:38 stefan Exp $' ! !