--- a/ByteArray.st Thu Mar 06 01:32:44 1997 +0100
+++ b/ByteArray.st Thu Mar 06 15:29:25 1997 +0100
@@ -77,7 +77,8 @@
|index "{ Class: SmallInteger }"
dstIndex "{ Class: SmallInteger }"
stop "{ Class: SmallInteger }"
- n "{ Class: SmallInteger }"
+ sixBits "{ Class: SmallInteger }"
+ n "{ Class: SmallInteger }"
sz "{ Class: SmallInteger }"
lastCharacter bytes|
@@ -89,26 +90,42 @@
lastCharacter := aString last.
lastCharacter asciiValue > 96 ifTrue:[
- stop := stop - 3 + lastCharacter asciiValue - 96
+ stop := stop - 3 + lastCharacter asciiValue - 96
].
bytes := self new:stop.
+
index := 1. dstIndex := 1.
[dstIndex <= stop] whileTrue:[
- "take 4 characters ..."
- n := (aString at:index) asciiValue - 32.
- n := (n bitShift:6) + ((aString at:index+1) asciiValue - 32).
- n := (n bitShift:6) + ((aString at:index+2) asciiValue - 32).
- n := (n bitShift:6) + ((aString at:index+3) asciiValue - 32).
- n := n bitXor:16r820820.
- index := index + 4.
- bytes at:dstIndex put:(n bitShift:-16).
- dstIndex < stop ifTrue:[
- bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF).
- dstIndex+2 <= stop ifTrue:[
- bytes at:dstIndex+2 put:(n bitAnd:16rFF).
- ]
- ].
- dstIndex := dstIndex + 3.
+ "take 4 characters ..."
+ sixBits := (aString at:index) asciiValue.
+ sixBits := sixBits bitAnd:16r3F.
+ n := sixBits.
+
+ sixBits := (aString at:index+1) asciiValue.
+ sixBits := sixBits bitAnd:16r3F.
+ n := (n bitShift:6) + sixBits.
+
+ sixBits := (aString at:index+2) asciiValue.
+ sixBits := sixBits bitAnd:16r3F.
+ n := (n bitShift:6) + sixBits.
+
+ sixBits := (aString at:index+3) asciiValue.
+ sixBits := sixBits bitAnd:16r3F.
+ n := (n bitShift:6) + sixBits.
+
+ index := index + 4.
+
+ "/ now have 24 bits in n
+
+ bytes at:dstIndex put:(n bitShift:-16).
+
+ dstIndex < stop ifTrue:[
+ bytes at:dstIndex+1 put:((n bitShift:-8) bitAnd:16rFF).
+ dstIndex+2 <= stop ifTrue:[
+ bytes at:dstIndex+2 put:(n bitAnd:16rFF).
+ ]
+ ].
+ dstIndex := dstIndex + 3.
].
^ bytes
@@ -120,6 +137,8 @@
ByteArray fromPackedString:(#[1 1 1 1 1 1 1 1] asPackedString)
"
+
+ "Modified: 6.3.1997 / 15:28:52 / cg"
!
uninitializedNew:anInteger
@@ -2244,5 +2263,5 @@
!ByteArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.75 1997-01-11 12:13:47 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.76 1997-03-06 14:29:25 cg Exp $'
! !