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

Sign up
Appearance settings

Commit 8431488

Browse 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 3b88aca commit 8431488

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

‎api/String.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ String::String(const char *cstr)
4545
if (cstr) copy(cstr, strlen(cstr));
4646
}
4747

48+
String::String(const char *cstr, unsigned int length)
49+
{
50+
init();
51+
if (cstr) copy(cstr, length);
52+
}
53+
4854
String::String(const String &value)
4955
{
5056
init();

‎api/String.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class String
6868
// fails, the string will be marked as invalid (i.e. "if (s)" will
6969
// be false).
7070
String(const char *cstr = "");
71+
String(const char *cstr, unsigned int length);
7172
String(const String &str);
7273
String(const __FlashStringHelper *str);
7374
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /