Skip to content

[SR-9311] SourceKit-LSP should not use String.Index.encodedOffset as UTF16 offset #551

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

Closed
rintaro mannequin opened this issue Nov 21, 2018 · 2 comments
Closed

[SR-9311] SourceKit-LSP should not use String.Index.encodedOffset as UTF16 offset #551

rintaro mannequin opened this issue Nov 21, 2018 · 2 comments
Labels
bug Something isn't working

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Nov 21, 2018

Previous ID SR-9311
Radar None
Original Reporter @rintaro
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s SourceKit-LSP
Labels Bug
Assignee None
Priority Medium

md5: 8dfc9af638c0545d5e232c1909733399

Issue Description:

String.Index.encodedOffset doesn't necessarily mean UTF16 offset.

In Swift4.2 on macOS, '"こんにちは".endIndex.encodedOffset' results 5, but in the current master, it's 15 probably because swiftlang/swift#20315 .

Moreover, if the string is backed by NSString it's 5 even in Swift5.

let str: String = "こんにちは"
print(str.endIndex.encodedOffset) // 15

import Foundation
let nsStr: NSString = "こんにちは"
let _nsStr = nsStr as String
print(_nsStr.endIndex.encodedOffset) // 5
@rintaro
Copy link
Mannequin Author

rintaro mannequin commented Nov 21, 2018

CC: @benlangmuir

@rintaro
Copy link
Mannequin Author

rintaro mannequin commented Nov 21, 2018

#14

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

No branches or pull requests

0 participants