[Proposal] Enum subsets

If this does get implemented, I would love to see an overload of String.data(using:) that accepts a subset of String.Encoding that is unicode-based and allows the method to return a non-optional Data

Since String guts are being re-implemented right now maybe you should talk about this with Michael_Ilseman ?

Can you all please remove me from recipients list? I unsubscribed from the mailing list because I’m no longer interested in participating in this group.

I believe I have fixed this so that you will not get further notifications. You had the setting enabled for:
Send me an email when someone quotes me, replies to my post, mentions my @username, or invites me to a topic

in your preferences.

String(decoding:as:) already does this:

let data = Data([0x41, 0x42])
let str = String(decoding: data, as: UTF8.self) // "AB"
type(of: str) // String.Type

Not all Unicode-based encodings are available. I only used it with UTF-8 so far. I’m pretty sure UTF-16 also works (though I don’t know if it handles different byte orders correctly).

The guts are pure ABI and have no API impact. String.Encoding subsets seem totally reasonable.

Anything new on this topic? I‘d love to see it in swift.

Not on my end. I am working on something else enum related and… if that ever lands I should be closer to maybe getting an implementation together for this.

Terms of Service

Privacy Policy

Cookie Policy