Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement string:substring #960

Open
jclark opened this issue Mar 8, 2022 · 2 comments
Open

Implement string:substring #960

jclark opened this issue Mar 8, 2022 · 2 comments

Comments

@jclark
Copy link
Contributor

jclark commented Mar 8, 2022

Implement in C the substring function defined in lang.string.

@jclark
Copy link
Contributor Author

jclark commented Mar 8, 2022

The substring function is defined here: https://ballerina.io/spec/lang/2022R1/#lang.string

The implementation should be added to runtime/string.c. The runtime representation of strings is described here: https://github.com/ballerina-platform/nballerina/blob/main/docs/rtvalue.md#string

Note that what makes this non-trivial is that startIndex and endIndex use units of code points not bytes.

@jclark
Copy link
Contributor Author

jclark commented Mar 13, 2022

There are also examples of how to work with the string representation in runtime/tests/string_*.c. The substring function will need tests added there.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants