Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fix two issues in utf8 <-> utf16 offset & lengths conversions #49

Merged
merged 2 commits into from
Jan 29, 2016
Merged

Fix two issues in utf8 <-> utf16 offset & lengths conversions #49

merged 2 commits into from
Jan 29, 2016

Conversation

alexdima
Copy link
Contributor

@zcbenz

I am sorry my previous pull request #46 introduced a regression around utf8 <-> utf16 conversion, specifically I misunderstood OnigResult.LengthAt to be the count of code points instead of the byte count -- it being the byte count makes a lot more sense.

I have added a regression test and removed OnigString.utf16OffsetIsCodePointEnd which is no longer needed.

@EvilBeaver discovered the issue in VS Code (microsoft/vscode#2170)

@alexdima
Copy link
Contributor Author

Please do not merge it in yet, I want to investigate why https://github.com/atom/first-mate/blob/master/spec/grammar-spec.coffee#L796 fails with this change

@lee-dohm
Copy link

Sounds good. I'll mark it as requires-changes for now then. Just @-mention me when you think it is ready for review 😀

@alexdima alexdima changed the title OnigResult.LengthAt represents byte count, not code point length Fix two issues in utf8 <-> utf16 offset & lengths conversions Jan 29, 2016
@alexdima
Copy link
Contributor Author

The second problem was a wrong assumption (again 😊) on my side that code points requiring 3 or 4 bytes in utf8 must necessarily require 4 bytes in utf16. The second commit fixes this assumption by actually recording where a code point starts in the utf16 string.

@lee-dohm Thank you, it is now ready for review 👍

@zcbenz
Copy link
Contributor

zcbenz commented Jan 29, 2016

👍

zcbenz added a commit that referenced this pull request Jan 29, 2016
Fix two issues in utf8 <-> utf16 offset & lengths conversions
@zcbenz zcbenz merged commit c2f225d into atom:master Jan 29, 2016
@alexdima
Copy link
Contributor Author

Thank you very much! ❤️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants