Skip to content

Could be more resilient to non-utf8-encoded output #2

@dabrahams

Description

@dabrahams

Here I think it would be better to accumulate everything in Data and only attempt to decode it when you finally need a string. Then you could (optionally) try multiple encodings and fall back to encoding-repairing conversion by appending a nul character and using String.decodeCString(p, as: UTF8.self, repairingInvalidCodeUnits: true).

guard let string = String(data: fileHandle.availableData, encoding: .utf8) else { return }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions