Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lower case UUID serialization #85

Open
Westacular opened this issue Apr 29, 2023 · 2 comments
Open

Support lower case UUID serialization #85

Westacular opened this issue Apr 29, 2023 · 2 comments
Assignees

Comments

@Westacular
Copy link

The UUID and NSUUID types have long been slightly out of compliance with RFC 4122, which specifies that the string representation of UUIDs should be in lower case. (I believe NSUUID has always used upper case in part because it predates that RFC?)

The use of upper case creates problems when interacting with external APIs that generate and send UUID values in their responses (in lowercase, as per the RFC) but expect exact string matches for these values in subsequent requests: a round-trip through a Swift using UUID will result in the value being transformed into an upper case spelling.

In my own projects, I've taken to using a LowercaseUUID type which wraps a UUID and overrides uuidString, description, and encode(to:) to apply a .lowercased() transformation in each case. However, it would be preferable if there was a way to specify this behaviour directly within Foundation, and it seems to me that this project presents an opportunity add this or alter the default.

@parkera
Copy link
Member

parkera commented May 9, 2023

For clarification -- the issue is mostly about how UUID encodes itself, and not getting a lowercased string at runtime (via uuidString)?

@Westacular
Copy link
Author

Yes, that's correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants