FourByteString.st
author Claus Gittinger <cg@exept.de>
Thu, 14 Apr 2016 12:53:36 +0200
changeset 3805 9cb0780df5fc
parent 3586 a6d20359cdf4
child 3826 63c5834d27c1
permissions -rw-r--r--
#OTHER by cg comment only

"
 COPYRIGHT (c) 2004 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libbasic2' }"

"{ NameSpace: Smalltalk }"

CharacterArray variableLongSubclass:#FourByteString
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Collections-Text'
!

!FourByteString class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2004 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    FourByteStrings are like strings, but storing 32bits per character.
    The integration of them into the system is not completed ....

    [author:]
        Claus Gittinger

    [see also:]
        Text TwoByteString UnicodeEncodedString
        StringCollection
"
! !

!FourByteString class methodsFor:'initialization'!

initialize
    "initialize the class - private"

    self flags:(Behavior flagLongs)

    "
     FourByteString initialize
    "

    "Modified: 22.4.1996 / 16:14:14 / cg"
! !

!FourByteString class methodsFor:'instance creation'!

basicNew:anInteger
    "return a new empty string with anInteger characters"

    ^ (super basicNew:anInteger) atAllPut:(Character space)

    "Modified: 26.2.1996 / 14:38:47 / cg"
!

uninitializedNew:anInteger
    "return a new empty string with anInteger characters"

    ^ super basicNew:anInteger

    "
        self uninitializedNew:10
    "
! !

!FourByteString methodsFor:'accessing'!

basicAt:index
    "return the character at position index, an Integer
     - reimplemented here since we return 32-bit characters"

    |val|

    val := super basicAt:index.
    ^ Character value:val
!

basicAt:index put:aCharacter
    "store the argument, aCharacter at position index, an Integer.
     Returns aCharacter (sigh).
     - reimplemented here since we store 32-bit characters"

    |val|

    val := aCharacter codePoint.
    super basicAt:index put:val.
    ^ aCharacter
! !

!FourByteString methodsFor:'encoding'!

utf8Encoded
    "Return my UTF-8 representation as a new String"

    ^ CharacterEncoderImplementations::ISO10646_to_UTF8 new encodeString:self
!

utf8EncodedOn:aStream
    "write to aStream in utf8 encoding"

    aStream nextPutAllUtf8:self.
! !

!FourByteString methodsFor:'queries'!

bitsPerCharacter
    "return the number of bits each character has.
     Here, 32 is returned (storing quad byte characters)."

    ^ 32
!

isWideString
    "true if I require more than one byte per character"

    ^ true
! !

!FourByteString class methodsFor:'documentation'!

version
    ^ '$Header$'
! !


FourByteString initialize!