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

[SR-13175] Swift.CWideChar should be an alias to Swift.Unicode.UTF16.CodeUnit #55617

Open
dduan opened this issue Jul 8, 2020 · 3 comments
Open
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@dduan
Copy link
Collaborator

dduan commented Jul 8, 2020

Previous ID SR-13175
Radar None
Original Reporter @dduan
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

md5: d3f9433fd64908e9337ff6efbf4f32db

Issue Description:

Today it is defined as an alias to {{Unicode.Scalar}}, which is a container struct for an {{UInt32}}. A better alias for it is {{Unicode.UTF16.CodeUnit}}.

@belkadan
Copy link
Contributor

belkadan commented Jul 8, 2020

That's not correct; it's only a UTF-16 code unit on Windows.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@grynspan
Copy link
Contributor

Neither of those types would be the right choice. One would expect CWideChar to map directly to wchar_t, such that a C function using wchar_t is directly interoperable with a Swift function using CWideChar (like how CInt and int are mapped today.)

Changing the definition of this type would most likely lead to binary compatibility problems on ABI-stable platforms (i.e. Darwin) so care would need to be taken. It might make more sense to deprecate CWideChar and replace it with e.g. typealias CWChar = wchar_t or equivalent.

@grynspan
Copy link
Contributor

I'm going to take this issue and use it to conditionally declare CWideChar as a 16-bit type on Windows, since its current declaration is incorrect there. Everywhere else (POSIX-like, at least) has standardized on 32-bit/UCS-4/UTF-32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

3 participants