Skip to content

Commit 2378d87

Browse files
committed
Swap and correct the documentation of isSpace() and isWhitespace()
Although the documentation previously matched what you might expect these functions to do based on their names, the actual behavior of the functions is the reverse. In addition to this, isWhitespace() matches on horizontal tab as well as space, which was not mentioned in the isSpace() documentation. The decision was made to leave the implementation of the functions as-is to avoid causing breakage and to correct the documentation to match the actual behavior of the functions. More information: arduino/ArduinoCore-API#27
1 parent 192ce1d commit 2378d87

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

Language/Functions/Characters/isSpace.adoc

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ subCategories: [ "Characters" ]
1717

1818
[float]
1919
=== Description
20-
Analyse if a char is the space character. Returns true if thisChar contains the space character.
20+
Analyse if a char is a white-space character. Returns true if the argument is a space, form feed (`'\f'`), newline (`'\n'`), carriage return (`'\r'`), horizontal tab (`'\t'`), or vertical tab (`'\v'`).
2121
[%hardbreaks]
2222

2323

@@ -34,7 +34,7 @@ isSpace(thisChar)
3434

3535
[float]
3636
=== Returns
37-
`true`: if thisChar is a space.
37+
`true`: if thisChar is a white-space character.
3838

3939
--
4040
// OVERVIEW SECTION ENDS
@@ -50,11 +50,11 @@ isSpace(thisChar)
5050

5151
[source,arduino]
5252
----
53-
if (isSpace(myChar)) { // tests if myChar is the space character
54-
Serial.println("The character is a space");
53+
if (isSpace(myChar)) { // tests if myChar is a white-space character
54+
Serial.println("The character is white-space");
5555
}
5656
else {
57-
Serial.println("The character is not a space");
57+
Serial.println("The character is not white-space");
5858
}
5959
----
6060

Language/Functions/Characters/isWhitespace.adoc

+5-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ subCategories: [ "Characters" ]
1717

1818
[float]
1919
=== Description
20-
Analyse if a char is a white space, that is space, formfeed ('\f'), newline ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab ('\v')).
21-
Returns true if thisChar contains a white space.
20+
Analyse if a char is a space character. Returns true if the argument is a space or horizontal tab (`'\t'`).
2221
[%hardbreaks]
2322

2423

@@ -34,7 +33,7 @@ isWhitespace(thisChar)
3433

3534
[float]
3635
=== Returns
37-
`true`: if thisChar is a white space.
36+
`true`: if thisChar is a space character.
3837

3938
--
4039
// OVERVIEW SECTION ENDS
@@ -50,11 +49,11 @@ isWhitespace(thisChar)
5049

5150
[source,arduino]
5251
----
53-
if (isWhitespace(myChar)) { // tests if myChar is a white space
54-
Serial.println("The character is a white space");
52+
if (isWhitespace(myChar)) { // tests if myChar is a space character
53+
Serial.println("The character is a space or tab");
5554
}
5655
else {
57-
Serial.println("The character is not a white space");
56+
Serial.println("The character is not a space or tab");
5857
}
5958
----
6059

0 commit comments

Comments
 (0)