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

Wstring: getBytes() method is not clear to use with passing number of bytes to fill in buffer #537

Open
Croody opened this issue Jun 20, 2023 · 0 comments

Comments

@Croody
Copy link

Croody commented Jun 20, 2023

When we pass buffer size to getBytes() accordingly to declared array size (buffer[bufSize]) then last index will be null. We must explicitly pass to getBytes() value [bufSize + 1] to properly get all bytes. This is not clear to use without take a look inside to getBytes() method.
For example:
String text{ "ABCDE" };
uint8_t buffer[text.length()] = {};
text.getBytes(buffer, text.length() + 1);

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

No branches or pull requests

1 participant