-
Notifications
You must be signed in to change notification settings - Fork 193
Enable string conversion in EUC-JP. #1296
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
base: main
Are you sure you want to change the base?
Conversation
@swift-ci Please test |
Sources/FoundationEssentials/String/StringProtocol+Essentials.swift
Outdated
Show resolved
Hide resolved
Sources/FoundationInternationalization/ICU/ICU+StringConverter.swift
Outdated
Show resolved
Hide resolved
Sources/FoundationEssentials/String/StringProtocol+Essentials.swift
Outdated
Show resolved
Hide resolved
7ae3f7f
to
b0a8981
Compare
@swift-ci Please test |
@parkera @jmschonfeld Thank you for reviewing. In response to your feedback, I've made some changes:
|
Please let me request reviews again as per changes above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good to me, but also want @jmschonfeld to chime in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for putting this together!
// but are not supported by corelibs-foundation. | ||
// We delegate conversion to ICU. | ||
guard let string = ( | ||
bytes.withContiguousStorageIfAvailable({ _icuMakeStringFromBytes($0, encoding: encoding) }) ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually sorry one more thing that I just caught - this _icuMakeStringFromBytes
function is only defined in !FOUNDATION_FRAMEWORK
builds so this fails to build with FOUNDATION_FRAMEWORK
enabled. Could you wrap this case in #if !FOUNDATION_FRAMEWORK
. For now in Foundation.framework this will fall back to NSString
below, and we can look at using ICU instead of NSString
in Foundation.framework in the future (since that may be a behavioral change. Same goes for the case in StringProtocol+Essentials.swift
as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review. This is indeed wrapped by #if !FOUNDATION_FRAMEWORK
already:
#if !FOUNDATION_FRAMEWORK
case .isoLatin1:
...
case .macOSRoman:
...
case .japaneseEUC:
...
#endif
} | ||
|
||
|
||
@_dynamicReplacement(for: _icuMakeStringFromBytes(_:encoding:)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This replaced function is only defined in !FOUNDATION_FRAMEWORK
builds, could we wrap this in #if !FOUNDATION_FRAMEWORK
as well so that it will build successfully in FOUNDATION_FRAMEWORK
mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is... not wrapped by #if
. I'm going to fix that. Thank you for the catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
96de131
to
bc1656d
Compare
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.
bc1656d
to
844479e
Compare
@swift-ci Please test |
Background: EUC-JP is not supported by OSS CoreFoundation, while it is supported by macOS Foundation Framework.
See #1016
This PR resolves the issue by calling ICU API if necessary.