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

Reproduce issue described in #45 - multi-byte characters are counted incorrectly. #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Dec 14, 2023

Multi-byte characters are counted incorrectly.

or

Rust and JS count string length differently 🙃

(at which point, our JS offset output is a bit misleading, because we don't exactly communicate that the ranges are byte offsets, and it's not super straight forward to convert from byte offsets to char offsets in JS)

@@ -37,6 +37,37 @@ describe("parse", function () {
]);
});

it("multi-byte characters", function () {
let contentLength = "안녕하세요 세계".length;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I defined all these lengths here because I can't count myself

type: "expression",
tagName: "template",
contents: "안녕하세요 세계",
range: {
Copy link
Contributor Author

@NullVoxPopuli NullVoxPopuli Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a range is always [start, end), just like String.prototype.slice
[inclusive, exclusive) or, from the frame of reference of the substring-in-question: [start index, index one character immediately after)

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

Successfully merging this pull request may close these issues.

1 participant