Skip to content

Swift should support kCFStringEncodingDOSLatinUS on Linux #1029

Open
@microtherion

Description

@microtherion

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions