Utf8
Description
Container class containing UTF-8 encoding.
@see Class Comments in <EsUnicodeEncoding> for usage examples.
Class Methods
None
Instance Methods
asUnicodeString:
   Answer a new unicode string instance from the receiver.
   If @repair is true, then invalid utf8 will be replaced with the unicode replacement character U+FFFD.
   
   Examples:
    'Grinning Face (U+1F600)'.
    self assert: [(Utf8 with: 16rF0 with: 16r9F with: 16r98 with: 16r80) asUnicodeString first name = 'GRINNING FACE'].
    
    'Invalid UTF8-encoding'.
    self assert: [[(Utf8 with: 233) asUnicodeString. false] on: Exception do: [:ex | ex exitWith: true]].
    
    'Repaired invalid UTF8-encoding'.
    self assert: [((Utf8 with: 233) asUnicodeString: true) = UnicodeScalar replacementCharacter asUnicodeString].

   Arguments:
    repair - <Boolean>    
   Answers:
    <UnicodeString>
isValid
   Answer true if the content of the container represents valid UTF-8 data.
   
   Examples:
    'Grinning Face (U+1F600)'.
    self assert: [(Utf8 with: 16rF0 with: 16r9F with: 16r98 with: 16r80) isValid].
    
    'Invalid UTF8-encoding'.
    self assert: [(Utf8 with: 233) isValid not]
   
   Answers:
    <Boolean> true if valid, false if invalid
Last modified date: 01/18/2023