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

Swift should support kCFStringEncodingDOSLatinUS on Linux #1029

Open
microtherion opened this issue Nov 1, 2024 · 1 comment
Open

Swift should support kCFStringEncodingDOSLatinUS on Linux #1029

microtherion opened this issue Nov 1, 2024 · 1 comment

Comments

@microtherion
Copy link

This might be another issue classified under the #1015 umbrella.

Summary:
The String(data:encoding:) constructor fails on Linux when encoding is kCFStringEncodingDOSLatinUS.

Steps To Reproduce:
ZIPFoundation is doing the following:

        let dosLatinUS = 0x400
        let dosLatinUSEncoding = CFStringEncoding(dosLatinUS)
        let dosLatinUSStringEncoding = CFStringConvertEncodingToNSStringEncoding(dosLatinUSEncoding)
        let codepage437 = String.Encoding(rawValue: dosLatinUSStringEncoding)
        let encoding = self.centralDirectoryStructure.usesUTF8PathEncoding ? .utf8 : codepage437

This code works on Apple platforms, but fails on Linux.

The reason CP437 is needed for ZIP file decoding is that the ZIP Specification specifies that the encoding is CP437, unless a UTF-8 flag is set. So for legacy ZIP files, CP437 must be assumed (although in practice, encodings were far more random).

@YOCKOW
Copy link
Member

YOCKOW commented Nov 3, 2024

Thank you. Added this to #1015.
However, I want to note that kCFStringEncodingDOSLatinUS is not one of CFStringBuiltInEncodings but one of External String Encodings that is not exposed to String.Encoding (yet).

In the context of the pitch about string encoding names, a suggestion to add new static properties to String.Encoding received some kind of negative feedbacks.

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

2 participants