arduino / arduino/reference-en

Define "whitespace" in String `trim` reference

Open
#707 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
No language data
Stars
173
Forks
704
PR merge metrics
No merged PRs in 30d

Description

https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/trim/
It states that it removes 'any leading and trailing whitespace'
'whitespace' isn't declared, Some websites states that /r/n are also whitespaces (char 10+13) but it does not remove these.

**What happened**
a string with /r/n at the end, did not get the /r/n removed
String a = "test" + char(10) + Char(13);
Serial.print(a.trim().length());

**What I expected**
That the /r and /n were removed from the string (they are whitespaces in my opinion)

**What should happen**
Either
1) Update the website to state what the 'whitespaces' are, and thus what it removes with 'trim()'
2) That the function is to be fixed and /r and /n being added to 'trim()' (and update the webpage?)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the linked String trim reference and compare its statement about whitespace with the reported char(10) and char(13) example. Decide whether the page should define the whitespace characters it removes or whether the requested behavior belongs in the implementation; done means the documented behavior and the example are unambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation, embedded-iot
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.