We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
md5: d145092765f170e4683f665e97822e31
relates to:
Issue Description:
The following line produces core dump on Linux: let _ = "\r\n".components(separatedBy: CharacterSet.whitespacesAndNewlines)
The text was updated successfully, but these errors were encountered:
The backtrace is:
4 libFoundation.so 0x00007f140474d8f2 _TTSf4s_n___TFC10Foundation8NSString9substringfT4withVS_8_NSRange_SS + 562 5 libFoundation.so 0x00007f1404741b2a _TFC10Foundation8NSString10componentsfT11separatedByVS_12CharacterSet_GSaSS_ + 474 6 libFoundation.so 0x00007f1404753381 _TFE10FoundationSS10componentsfT11separatedByVS_12CharacterSet_GSaSS_ + 49 7 libFoundation.so 0x00007f140fde1098 _TFE10FoundationSS10componentsfT11separatedByVS_12CharacterSet_GSaSS_ + 191421768
On closer examination I found that the String.init(utf16View) call here, returns nil: https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSString.swift#L349
The reason for String(utf16View) returning nil can be seen the following code that prints nil on both Darwin and Linux:
let str = "\r\n" let start = str.utf16.startIndex let min = start.advanced(by: 1) let max = start.advanced(by: 1) print(String(str.utf16[min..<max]))
I'd propose that on line 349 in NSString.swift, we check for nil and return an empty string for a nil.
#647 – This doesn't fix SR-1627
Sorry, something went wrong.
In short for "\r\n", the utf16View[0..<0] is "" but utf16View[1..<1] is nil
This behaviour is consistent with Darwin
See this: http://swiftlang.ng.bluemix.net/#/repl/57de338f703023246976ee34
"\r\n" is (are?) counted as 1 character.
print("\r\n".characters.count) //this prints 1
That explains why "\r\n". utf16View[1..<1] returns nil
pushkarnk
No branches or pull requests
Additional Detail from JIRA
md5: d145092765f170e4683f665e97822e31
relates to:
Issue Description:
The following line produces core dump on Linux:
let _ = "\r\n".components(separatedBy: CharacterSet.whitespacesAndNewlines)
The text was updated successfully, but these errors were encountered: