URLSession.AsyncBytes.lines for UTF16

The async lines property is tremendously useful to asynchronously ingest a file step by step. However I've run into a wall when faced with a UTF16 file. lines assumes the data is UTF8. Is there any simple way of using this AsyncSequence to read a UTF16 instead ? I would like to avoid reading the entire file into memory.

It's been on my list to add at some point, but I'd like to sort out our unicode decoding infrastructure a bit more first.

If you wanted to write your own version for now, this pull request has some code you could use as a starting point: https://github.com/apple/swift-corelibs-foundation/pull/3036

2 Likes