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

☂️ String.init(data:encoding:)/String.data(using:) regression. #1015

Open
5 tasks
YOCKOW opened this issue Oct 27, 2024 · 7 comments
Open
5 tasks

☂️ String.init(data:encoding:)/String.data(using:) regression. #1015

YOCKOW opened this issue Oct 27, 2024 · 7 comments
Assignees

Comments

@YOCKOW
Copy link
Member

YOCKOW commented Oct 27, 2024

This is an umbrella issue that is tracking regression of String.init(data:encoding:)/String.data(using:).

DataString

StringData

@Frizlab
Copy link

Frizlab commented Oct 27, 2024

Should this one be part of this or is the current behavior considered the correct one?

@YOCKOW YOCKOW changed the title ☂️ String.data(using: encoding) regression. ☂️ String.init(data:encoding:)/String.data(using:) regression. Oct 28, 2024
@YOCKOW
Copy link
Member Author

YOCKOW commented Oct 28, 2024

Should this one be part of this or is the current behavior considered the correct one?

Thank you. I added it.
But I'm not sure whether or not it should be reopened because Darwin's behavior seems to have also changed.

@YOCKOW
Copy link
Member Author

YOCKOW commented Nov 4, 2024

@parkera
I think these are signals which imply that the decision not to support string encodings we are still using is a little slapdash.
On the other hand, we have to consider what @omochi said in #925:

String.data is defined in FoundationEssentials, not in FoundationInternationalization, so ICU cannot be used.

IMHO, options are:

  • To lower data(using:) onto FoundationInternationalization to use ICU.
  • To implement string converters in pure-Swift.
  • To ignore these signals.

@parkera
Copy link
Contributor

parkera commented Nov 4, 2024

We need data(using:) for non-internationalization related APIs, which is why it is implemented in Essentials. I don't quite understand option 1 here, because FoundationInternationalization is layered above Essentials.

We can move more encoding conversions to be implemented in Swift over time. However, if importing the full Foundation module on Linux we also might be able to support the larger set of encodings by FoundationEssentials "upcalling" into swift-corelibs-foundation's CoreFoundation string encoding conversion.

@YOCKOW
Copy link
Member Author

YOCKOW commented Nov 5, 2024

I don't quite understand option 1 here, because FoundationInternationalization is layered above Essentials.

I'm sorry, but I misworded due to my cultural background. ("lower" → "lift"?)
I meant option 1 was to let data(using:) use directly ICU in any way.

if importing the full Foundation module on Linux we also might be able to support the larger set of encodings by FoundationEssentials "upcalling" into swift-corelibs-foundation's CoreFoundation string encoding conversion.

Is this some kind of "future direction"?
I thought current available stopgap workaround was to call CF APIs directly.

@parkera
Copy link
Contributor

parkera commented Nov 5, 2024

Take a look at the technique we use in Calendar_Cache.swift for an example. When on Darwin (where this is all one module) or when on non-Darwin and a callback has been registered, we can allow the lower-level Calendar(identifier:) API to support identifiers that only work when FoundationInternationalization is loaded.

@YOCKOW
Copy link
Member Author

YOCKOW commented Nov 5, 2024

I didn't know such technique. I appreciate your instruction. I've been illuminated.
Thank you.

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

5 participants