SF-0033: Implement String.Encoding.ianaName and String.Encoding(ianaName:).#1286
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
dd0b16c to
1ae2a4c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
1ae2a4c to
4d87ed8
Compare
String.Encoding.ianaName and String.Encoding(ianaName:).String.Encoding.ianaName and String.Encoding(ianaName:).
This comment was marked as outdated.
This comment was marked as outdated.
217c46d to
9cd5c9a
Compare
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
This comment was marked as outdated.
This comment was marked as outdated.
9cd5c9a to
3e9aef4
Compare
3e9aef4 to
ac42127
Compare
|
@swift-ci Please test |
|
I've made this PR ready for review. cc: Foundation Workgroup |
|
@itingliu |
0045a48 to
e674fa6
Compare
b7702b3 to
8f84db7
Compare
|
@swift-ci Please test |
|
@swift-ci test |
itingliu
left a comment
There was a problem hiding this comment.
I also like this simplified version. Thank you! just had a few minor comments
| /// to determine which encoding is suitable. | ||
| @available(FoundationPreview 6.3, *) | ||
| public init?(ianaName charsetName: String) { | ||
| let possibilities: [String.Encoding] = [ |
There was a problem hiding this comment.
Would it work if you write
let possibilities: [IANACharset] = {...
and below just do
func __determineEncoding() -> String.Encoding? {
for ianaCharset in possibilities {
if ianaCharset.matches(charsetName) {
return encoding
}
}
return nil
}
Am I missing anything?
There was a problem hiding this comment.
Won't we lose encoding for return encoding in that implementation?
| return nil | ||
| } | ||
|
|
||
| guard let encoding = __determineEncoding() else { |
There was a problem hiding this comment.
And to simply this even further, it looks like this logic inside func __determineEncoding() doesn't even needed to be extracted in a function since it's only used once?
There was a problem hiding this comment.
The reason why nested function is used is just because of readability since self = nil; return is invalid in Swift.
Sorry, we can write self = encoding; return...
I'm fixing it.
There was a problem hiding this comment.
I've fixed String.Encoding(ianaName:).
I hope that this is in line with your intention.
|
@swift-ci Please test |
|
What's changed since 8f84db7:
|
|
I sincerely appreciate the reviews and approvals. Thank you so much. |
Implementation of the proposal: #1243 (SF-0033)