-
Notifications
You must be signed in to change notification settings - Fork 188
swift 6 cannot open correctly a windowsCP1252 file in linux (worked on swift 5 and macos) #1216
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
Comments
I can agree with that. We also have this issue, by reading a file from Windows. We read large TXT files line by line. We do this using a FileHandle. If we use the Swift windowsCP1252 encoding, we do not receive a single line. This situation exists not only under Linux but also under Windows. We have implemented the WindowsCP-1252 encoding manually.
Just for the sake of completeness, we compiled our application with the latest Swift SDK for Windows at the time. (Swift 6.0.1) |
You can simply use the Default Swift Encoding mechanism when you running the App on macOS. This can be archived by the following change:
|
My minimal example indicates that the native WindowsCP1252 encoding has failed. I have tested this under Windows Server 2022. Swift version 6.0.3 (swift-6.0.3-RELEASE)
macOS Output:
Windows Output:
|
There are more problems regarding encoding: The following code prints an empty array. Take out the line break, and it prints the correct result. let str =
"""
a
b
"""
let data = str.data(using: .isoLatin1) ?? Data()
print(Array(data)) |
...Also tested with Swift 6.1 (dev, downloaded today), the problems persist. |
The cause of the bug is that when |
isoLatin1 is implemented, however. That sounds like a different bug, which we should open a separate issue for. |
See swiftlang/swift-corelibs-foundation#5193 which will finish the full resolution of this bug by providing the swift-corelibs-foundation upcall for windowsCP1252 (or other) encodings. |
Description
Opening a file that is an export of transactions from an spanish bank (Caixa enginyers) which is an xls (html+latin1252) it gives a bad format using swift 6 compiler in linux. In mac-os or using swift 5.10 compiler works fine
Reproduction
Download the sample file:
https://github.com/Dracks/mr-scrooge/blob/mr-scrooge-3.0.0/src/swift-server-tests/test_files/MovimientosCuenta.xls
Expected behavior
get's the contents of the file in fileString variable. (Now the second ward execute the else case)
Environment
Swift version 6.0.2 (swift-6.0.2-RELEASE)
Target: x86_64-unknown-linux-gnu
Additional information
The link is a sample file exported from my bank, and anonymized, that I've got to run tests of my app. But today I expecuted it on my machine using the original file downloaded from the bank account and the same happened.
The text was updated successfully, but these errors were encountered: