Skip to content
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

[SR-5425] Data slices do not convert to String properly #3837

Closed
CharlesJS opened this issue Jul 11, 2017 · 0 comments
Closed

[SR-5425] Data slices do not convert to String properly #3837

CharlesJS opened this issue Jul 11, 2017 · 0 comments

Comments

@CharlesJS
Copy link

Previous ID SR-5425
Radar None
Original Reporter @CharlesJS
Type Bug
Status Resolved
Resolution Duplicate
Environment

Xcode 9 beta 3
(current trunk is failing to build, so can't test it there at the moment)

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 04098965672b58e6d129b17146412d61

duplicates:

  • SR-5426 Data slices crash when converted to NSData

Issue Description:

If a Data slice is constructed using a partial range, it will fail to convert to a String properly, as the code below demonstrates:

import Foundation

let data = "FooBar".data(using: .ascii)!
let slice = data[3...]

let string = String(data: slice, encoding: .ascii)
print(string) // nil

Constructing the slice using 3..<6 instead of 3... causes it to work.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant