Skip to content

Add an upcall point to swift-corelibs-foundation for String encoding conversion #1217

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

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

parkera
Copy link
Contributor

@parkera parkera commented Mar 19, 2025

Add an upcall to swift-corelibs-foundation for converting String encodings that swift-foundation does not implement.

Partially resolves #1216.

@parkera parkera requested a review from jmschonfeld March 19, 2025 16:49
@parkera
Copy link
Contributor Author

parkera commented Mar 19, 2025

@swift-ci test

@parkera
Copy link
Contributor Author

parkera commented Mar 19, 2025

Will, of course, need a follow up in swift-corelibs-foundation to replace the function with one that calls into NSString's conversion function.

@@ -91,6 +91,14 @@ extension UInt16 {

// These provides concrete implementations for String and Substring, enhancing performance over generic StringProtocol.

#if !FOUNDATION_FRAMEWORK
@_spi(SwiftCorelibsFoundation)
dynamic public func _cfStringEncodingConvert(string: String, using encoding: UInt, allowLossyConversion: Bool) -> Data? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a similar up-call for the bytes --> String direction so that we support decoding as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done.

@parkera
Copy link
Contributor Author

parkera commented Mar 19, 2025

@swift-ci test

@parkera
Copy link
Contributor Author

parkera commented Mar 21, 2025

@swift-ci test

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

Successfully merging this pull request may close these issues.

swift 6 cannot open correctly a windowsCP1252 file in linux (worked on swift 5 and macos)
2 participants