changed #nextPut: - multibyte caharcters
authorStefan Vogel <sv@exept.de>
Thu, 24 Apr 2008 16:55:58 +0200
changeset 1978 f7330488b12c
parent 1977 d4a04a73f200
child 1979 6eff3f1f1b80
changed #nextPut: - multibyte caharcters more examples
CRC32Stream.st
--- a/CRC32Stream.st	Thu Apr 24 16:49:13 2008 +0200
+++ b/CRC32Stream.st	Thu Apr 24 16:55:58 2008 +0200
@@ -43,6 +43,17 @@
                                                                 [exEnd]
 
                                                                 [exBegin]
+    self information:(CRC32Stream new
+                            nextPut:$r;
+                            nextPut:$e;
+                            nextPut:$s;
+                            nextPut:$u;
+                            nextPut:$m;
+                            nextPut:$e;
+                            hashValue) hexPrintString
+                                                                [exEnd]
+
+                                                                [exBegin]
     self information:(CRC32Stream new nextPut:4711; hashValue) printString
                                                                 [exEnd]
 
@@ -147,8 +158,16 @@
     ].
 
     arg isCharacter ifTrue:[
-        crc := (CrcTable at:((crc bitXor:arg codePoint) bitAnd:16rFF)+1) 
-               bitXor:(crc bitShift:-8).
+        byte := arg codePoint.
+        byte < 256 ifTrue:[
+            crc := (CrcTable at:((crc bitXor:byte) bitAnd:16rFF)+1) 
+                   bitXor:(crc bitShift:-8).
+            ^ self.
+        ].
+        byte digitBytes do:[:eachByte|
+            crc := (CrcTable at:((crc bitXor:eachByte) bitAnd:16rFF)+1) 
+                   bitXor:(crc bitShift:-8).
+        ].
         ^ self.
     ].
 
@@ -179,7 +198,7 @@
 !CRC32Stream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/CRC32Stream.st,v 1.4 2008-04-24 14:49:13 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/CRC32Stream.st,v 1.5 2008-04-24 14:55:58 stefan Exp $'
 ! !
 
 CRC32Stream initialize!