Utf32
Description
Container class containing UTF-32 platform-endian encoding.
@see Class Comments in <EsUnicodeEncoding> for usage examples.
Class Methods
asUnicodeString:repair:
  Answer a new unicode string instance using utf32 bytes from @aByteObject
     If @repair is true, then invalid utf32 will be replaced with the unicode replacement character U+FFFD.
     
     Examples:
        'Grinning Face (U+1F600)'.
        self assert: [(Utf32LE asUnicodeString: (Utf32LE with: 16r1F600)) first name = 'GRINNING FACE'].
        
        'Invalid UTF32-encoding'.
        self assert: [[Utf32LE asUnicodeString: (Utf32LE with: 16rD800) repair: false. false] on: Exception do: [:ex | ex exitWith: true]].
        
        'Repaired invalid UTF8-encoding'.
        self assert: [(Utf32LE asUnicodeString: (Utf32LE with: 16rD800) repair: true) = UnicodeScalar replacementCharacter asUnicodeString].
    
     Arguments:
        aByteOrLongObject - <ByteArray | Utf32>
        repair - <Boolean>
     Answers:
        <UnicodeString>
     Raises:
        <Exception> EsPrimErrValueOutOfRange if @anObject contains invalid bytes and @repair is false
Instance Methods
isValid
  Answer true if the content of the container represents valid UTF-32 data
     encoded in the endian type defined by the container.
     
     Examples:
        'Grinning Face (U+1F600) in platform endian'.
        self assert: [
            System bigEndian
                ifTrue: [(Utf32 with: 16r1F600) isValid]
                ifFalse: [(Utf32 with: 16r1F600) isValid]].
        
        'Invalid because of isolated surrogate - 16rD800'.
        self assert: [(Utf32LE with: 16r1F600 with: 16rD800) isValid not]
     
     Answers:
        <Boolean> true if valid, false if invalid
Last modified date: 01/06/2026