Skip to content

Discrepancy: String.data(using: .japaneseEUC) returns nil on non-Darwin. #1016

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

Open
YOCKOW opened this issue Oct 28, 2024 · 3 comments · May be fixed by #1296
Open

Discrepancy: String.data(using: .japaneseEUC) returns nil on non-Darwin. #1016

YOCKOW opened this issue Oct 28, 2024 · 3 comments · May be fixed by #1296
Assignees

Comments

@YOCKOW
Copy link
Member

YOCKOW commented Oct 28, 2024

Given the following code:

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

Results are:

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

This is not regression but discrepancy which should be also fixed.

@YOCKOW YOCKOW changed the title Discrepancy: String.data(using: . japaneseEUC) returns nil on non-Darwin. Discrepancy: String.data(using: .japaneseEUC) returns nil on non-Darwin. Oct 28, 2024
@parkera
Copy link
Contributor

parkera commented May 13, 2025

Resolved by #1217 as long as Foundation is imported.

@parkera parkera closed this as completed May 13, 2025
@parkera
Copy link
Contributor

parkera commented May 13, 2025

Actually - @YOCKOW can you verify that?

@YOCKOW
Copy link
Member Author

YOCKOW commented May 14, 2025

While I confirmed ISO-2022-JP was OK, EUC-JP seems still broken.

Edit: I'm sorry. This issue is not regression. It has been existing from a long time ago. I'll try to tackle on this separately...

@YOCKOW YOCKOW reopened this May 14, 2025
@YOCKOW YOCKOW self-assigned this May 15, 2025
YOCKOW added a commit to YOCKOW/swift-foundation that referenced this issue May 16, 2025
Background: EUC-JP is not supported by OSS CoreFoundation, while it is supported by macOS Foundation Framework.
See swiftlang#1016

This commit resolves the issue by calling ICU API if necessary.
@YOCKOW YOCKOW linked a pull request May 16, 2025 that will close this issue
@YOCKOW YOCKOW linked a pull request May 16, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants