Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8289b2d

Browse filesBrowse files
Add String(char *, unsigned) constructor
This constructor allows converting a buffer containing a non-nul-terminated string to a String object, by explicitely passing the length.
1 parent 015b004 commit 8289b2d
Copy full SHA for 8289b2d

File tree

Expand file treeCollapse file tree

2 files changed

+7
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-0
lines changed

‎hardware/arduino/avr/cores/arduino/WString.cpp

Copy file name to clipboardExpand all lines: hardware/arduino/avr/cores/arduino/WString.cpp
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ String::String(const char *cstr)
3131
if (cstr) copy(cstr, strlen(cstr));
3232
}
3333

34+
String::String(const char *cstr, unsigned int length)
35+
{
36+
init();
37+
if (cstr) copy(cstr, length);
38+
}
39+
3440
String::String(const String &value)
3541
{
3642
init();

‎hardware/arduino/avr/cores/arduino/WString.h

Copy file name to clipboardExpand all lines: hardware/arduino/avr/cores/arduino/WString.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class String
5757
// fails, the string will be marked as invalid (i.e. "if (s)" will
5858
// be false).
5959
String(const char *cstr = "");
60+
String(const char *cstr, unsigned int length);
6061
String(const String &str);
6162
String(const __FlashStringHelper *str);
6263
#ifdef __GXX_EXPERIMENTAL_CXX0X__

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.