Skip to content

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

Open
@Croody

Description

@Croody

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions