arduino / arduino/ArduinoCore-avr
Wstring: getBytes() method is not clear to use with passing number of bytes to fill in buffer
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
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);
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the String getBytes() method and reproduce the issue's buffer example with the declared array size and the larger length. Clarify the documented relationship between the buffer size, the requested byte count, and the terminating null byte; done means the API guidance makes the required usage unambiguous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100