swiftlang / swift-foundation

The Foundation project
Apache License 2.0
2.4k stars 160 forks source link

Regression: `String.data(using: .iso2022JP)` unexpectedly returns `nil` on non-Darwin. #1014

Open YOCKOW opened 2 weeks ago

YOCKOW commented 2 weeks ago

Given the following code:

import Foundation
print("Hello, world!".data(using: .iso2022JP) as Any)

Results are:

OS Swift Result
macOS 5.10 "Optional(13 bytes)"
Ubuntu 5.10 "Optional(13 bytes)"
macOS 6.0 "Optional(13 bytes)"
Ubuntu 6.0 "nil"

This is regression from Swift 6 on Linux. Note that ISO-2022-JP is often used for MIME(Email) in Japan.

Relates to: https://github.com/swiftlang/swift-foundation/issues/925