Skip to content

Commit ecfafe3

Browse files
committed
Add String(char *, unsigned) constructor
From upstream ArduinoCore-API commit 84314888a8a73b643469c5609beed6d21d1c037a
1 parent c606292 commit ecfafe3

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cores/esp32/WString.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ String::String(const char *cstr) {
3535
copy(cstr, strlen(cstr));
3636
}
3737

38+
String::String(const char *cstr, unsigned int length) {
39+
init();
40+
if (cstr)
41+
copy(cstr, length);
42+
}
43+
3844
String::String(const String &value) {
3945
init();
4046
*this = value;

cores/esp32/WString.h

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class String {
5555
// fails, the string will be marked as invalid (i.e. "if (s)" will
5656
// be false).
5757
String(const char *cstr = "");
58+
String(const char *cstr, unsigned int length);
5859
String(const String &str);
5960
String(const __FlashStringHelper *str);
6061
#ifdef __GXX_EXPERIMENTAL_CXX0X__

0 commit comments

Comments
 (0)