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

std.unicode: add utf16 byte length and codepoints counting routines #11663

Merged
merged 2 commits into from Sep 14, 2022

Conversation

matu3ba
Copy link
Contributor

@matu3ba matu3ba commented May 17, 2022

  • comptime and runtime tests are based on tests for counting utf8 code points

@matu3ba
Copy link
Contributor Author

matu3ba commented May 17, 2022

justification is existence of utf8CountCodepoints
personal goal: finish the basic stuff for rosettacode like http://www.rosettacode.org/wiki/String_length#Zig

@matu3ba matu3ba changed the title std.unicode: make calcUtf16LeLen pub fn std.unicode: calcUtf16LeLen and utf16CountCodepoints May 17, 2022
@matu3ba matu3ba changed the title std.unicode: calcUtf16LeLen and utf16CountCodepoints std.unicode: add utf16 byte length and codepoints counting routines May 17, 2022
@ifreund
Copy link
Member

ifreund commented May 17, 2022

I notice that the doc comment for utf8CountCodepoints() says /// Asserts that the data is valid UTF-8. but it doesn't actually seem to assert this and rather returns an error.

It'd be worth considering whether that behavior is more desirable. At the very least the doc comment should be fixed.

Jan Philipp Hafer added 2 commits May 17, 2022 18:54
* comptime and runtime tests are based on tests for counting utf8 code points
also remove 2 redundant and outcommented tests
@matu3ba
Copy link
Contributor Author

matu3ba commented May 17, 2022

Suggestions by @ifreund were applied. Note, that I did not modify that function.
No idea, why git was unable to keep commit history during rebase on top of master, which did not touch unicode.zig.

@andrewrk andrewrk merged commit 0931dda into ziglang:master Sep 14, 2022
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.

None yet

3 participants