#hexPrintXX:withSeparator:
authorStefan Vogel <sv@exept.de>
Mon, 19 Jun 2006 13:33:44 +0200
changeset 9379 b7e6cbe411f7
parent 9378 f489ea7dc8b6
child 9380 31213ffdf7c1
#hexPrintXX:withSeparator:
ByteArray.st
--- a/ByteArray.st	Mon Jun 19 13:17:30 2006 +0200
+++ b/ByteArray.st	Mon Jun 19 13:33:44 2006 +0200
@@ -2818,6 +2818,20 @@
     "
 !
 
+hexPrintOn:aStream withSeparator:aSeparatorStringOrCharacter
+    "print as hex string, eg: 'FF:02:43'"
+
+    self do:[:byte|
+        byte printOn:aStream base:16 size:2 fill:$0.
+    ] separatedBy:[
+        aSeparatorStringOrCharacter printOn:aStream
+    ].
+
+    "
+      #[1 2 3 4 10 17] hexPrintOn:Transcript withSeparator:$:
+    "
+!
+
 hexPrintString
     "print as hex string, eg: 'FF0243'.
      This string can be used in #fromHexString: to recreate the byteArray"
@@ -2839,6 +2853,20 @@
     "
 !
 
+hexPrintStringWithSeparator:aSeparatorStringOrCharacter
+    "print as hex string, eg: 'FF:02:43'."
+
+    |s|
+
+    s := '' writeStream.
+    self hexPrintOn:s withSeparator:aSeparatorStringOrCharacter.
+    ^ s contents.
+
+    "
+      #[1 2 3 4 10 17] hexPrintStringWithSeparator:$:
+    "
+!
+
 printOn:aStream
     "append a printed representation to aStream"
 
@@ -3126,6 +3154,7 @@
     "
 ! !
 
+
 !ByteArray methodsFor:'searching'!
 
 indexOf:aByte startingAt:start
@@ -3215,5 +3244,5 @@
 !ByteArray class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.173 2006-06-14 10:06:52 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ByteArray.st,v 1.174 2006-06-19 11:33:44 stefan Exp $'
 ! !