diff -r 47ab0b47e9c9 -r 5ef1a009d69d CharacterArray.st --- a/CharacterArray.st Tue Feb 16 15:06:54 2016 +0100 +++ b/CharacterArray.st Tue Feb 16 16:10:10 2016 +0100 @@ -320,6 +320,7 @@ "Created: 3.8.1997 / 18:16:40 / cg" ! ! + !CharacterArray class methodsFor:'cleanup'! lowSpaceCleanup @@ -2761,14 +2762,15 @@ return a byteArray containing single-, double- or even 4-bytewise values. The size of the returned byteArray will be the strings size multiplied by the size required for the largest character. + Attention: The bytes are in native byte order. Caveat: better use utf8Encoded, to get reproducable results" |bytes sz bytesPerCharacter idx str| str := self string. str ~~ self ifTrue:[ - "/ for text and other wrappers - ^ str asByteArray + "/ for text and other wrappers + ^ str asByteArray ]. "/ for real strings, a fallback @@ -2777,25 +2779,41 @@ bytes := ByteArray new:(sz * bytesPerCharacter). idx := 1. self do:[:char | - |code| - - code := char codePoint. - bytesPerCharacter == 2 ifTrue:[ - bytes unsignedShortAt:idx put:code - ] ifFalse:[ - bytesPerCharacter == 4 ifTrue:[ - bytes unsignedLongAt:idx put:code - ] ifFalse:[ - bytes at:idx put:code - ]. - ]. - idx := idx + bytesPerCharacter. + |code| + + code := char codePoint. + bytesPerCharacter == 2 ifTrue:[ + bytes unsignedShortAt:idx put:code + ] ifFalse:[ + bytesPerCharacter == 4 ifTrue:[ + bytes unsignedLongAt:idx put:code + ] ifFalse:[ + bytes at:idx put:code + ]. + ]. + idx := idx + bytesPerCharacter. ]. ^ bytes "Created: / 27-07-2011 / 00:56:17 / cg" ! +asByteArrayMSB:msb + "depending on the size of the characters in the receiver, + return a byteArray containing single-, double- or even 4-bytewise values. + The size of the returned byteArray will be the strings size multiplied by the + size required for the largest character. + Caveat: better use utf8Encoded, to get reproducable results" + + |ba| + + ba := self asByteArray. "/ native order + UninterpretedBytes isBigEndian ~~ msb ifTrue:[ + ba swapBytes + ]. + ^ ba +! + asCollectionOfLines "return a collection containing the lines (separated by cr) of the receiver. If multiple cr's occur in a row, the result will @@ -4435,6 +4453,8 @@ ! ! + + !CharacterArray methodsFor:'matching - glob expressions'! compoundMatch:aString @@ -7610,6 +7630,7 @@ ^ aVisitor visitString:self with:aParameter ! ! + !CharacterArray class methodsFor:'documentation'! version