--- a/CharacterArray.st Mon Jul 25 12:26:29 2011 +0200
+++ b/CharacterArray.st Wed Jul 27 00:59:12 2011 +0200
@@ -2260,6 +2260,31 @@
"
!
+asByteArray
+ |bytes sz bytesPerCharacter idx|
+
+ sz := self size.
+
+ bytesPerCharacter := self bitsPerCharacter // 8.
+ bytes := ByteArray new:(sz * bytesPerCharacter).
+ idx := 1.
+ self do:[:char |
+ bytesPerCharacter == 2 ifTrue:[
+ bytes unsignedShortAt:idx put:char asciiValue
+ ] ifFalse:[
+ bytesPerCharacter == 2 ifTrue:[
+ bytes unsignedLongAt:idx put:char asciiValue
+ ] ifFalse:[
+ self error.
+ ].
+ ].
+ idx := idx + bytesPerCharacter.
+ ].
+ ^ bytes
+
+ "Created: / 27-07-2011 / 00:56:17 / cg"
+!
+
asCollectionOfLines
"return a collection containing the lines (separated by cr)
of the receiver. If multiple cr's occur in a row, the result will
@@ -5842,11 +5867,11 @@
!CharacterArray class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.456 2011-07-24 06:55:24 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.457 2011-07-26 22:59:12 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.456 2011-07-24 06:55:24 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/CharacterArray.st,v 1.457 2011-07-26 22:59:12 cg Exp $'
! !
CharacterArray initialize!