Skip to content

Support printing constant strings containing nulls #5747

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions hardware/arduino/avr/cores/arduino/Print.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class Print
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
template<size_t N>
inline size_t write(const char (str&)[N]) {
return write((const uint8_t *)str, N-1);
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
Expand All @@ -58,6 +62,10 @@ class Print
size_t print(const __FlashStringHelper *);
size_t print(const String &);
size_t print(const char[]);
template<size_t N>
inline size_t print(const char (str&)[N]) {
return write(str);
}
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
Expand All @@ -70,6 +78,12 @@ class Print
size_t println(const __FlashStringHelper *);
size_t println(const String &s);
size_t println(const char[]);
template<size_t N>
inline size_t println(const char (str&)[N]) {
size_t n = print(str);
n += println();
return n;
}
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
Expand Down