user83275: This Code:
String S0 = "";
String S1 = "1";
String S2 = "12";
String S3 = "123";
String S4 = "1234";
String S5 = "12345";
String S6 = "123456";
String S7 = "1234567";
String S8 = "12345678";
String S9 = "123456789";
String S10 = "1234567890";
String S11 = "1234567890a";
String S12 = "1234567890ab";
String S13 = "1234567890abc";
String S14 = "1234567890abcd";
String S15 = "1234567890abcde";
String S16 = "1234567890abcdef";
String S17 = "1234567890abcdefg";
String S18 = "1234567890abcdefgh";
String S19 = "1234567890abcdefghi";
String S20 = "1234567890abcdefghij";
Serial.printf("(0):%s\n", S0);
Serial.printf("(1):%s\n", S1);
Serial.printf("(2):%s\n", S2);
Serial.printf("(3):%s\n", S3);
Serial.printf("(4):%s\n", S4);
Serial.printf("(5):%s\n", S5);
Serial.printf("(6):%s\n", S6);
Serial.printf("(7):%s\n", S7);
Serial.printf("(8):%s\n", S8);
Serial.printf("(9):%s\n", S9);
Serial.printf("(10):%s\n", S10);
Serial.printf("(11):%s\n", S11);
Serial.printf("(12):%s\n", S12);
Serial.printf("(13):%s\n", S13);
Serial.printf("(14):%s\n", S14);
Serial.printf("(15):%s\n", S15);
Serial.printf("(16):%s\n", S16);
Serial.printf("(17):%s\n", S17);
Serial.printf("(18):%s\n", S18);
Serial.printf("(19):%s\n", S19);
Serial.printf("(20):%s\n", S20);

Gives This Result:
(0):
(1):1
(2):12
(3):123
(4):1234
(5):12345
(6):123456
(7):1234567
(8):12345678
(9):123456789
(10):�H�?
(11):�^�?
(12):_�?
(13):�_�?
(14):`�?
(15):0`�?
(16):�`�?
(17):a�?
(18):@a�?
(19):pa�?
(20):�a�?

Any ideas??
PS: IT IS OBVIOUS that for whatever platform it is being used, it is working for short strings and not for longer strings! And it has been answered in the comments after you have closed it! So if you do not know the answer instead of closing, maybe it is better to leave it for others to answer it...

user71575: (Community Wiki answer assembled from the comments)
Noting that the standard Arduino core doesn't have a Serial.printf() function. The ESP32 core does.
You need .c_str() in your calls. .printf() is a variadic function which doesn't really have access to any sort of destination type to do conversions; it relies entirely on your passing the correct format specifiers. It is just supplying the bytes to the String object, which is not simply a const char * (specified %s). If you're curious, the behaviour difference you're seeing is down to whether "small string optimization" is being used.
Short string optimization is where shorter strings are stored directly in the object and for longer strings it's used as pointers.
The suggested solution is to use: Serial.printf("%s",Sxx.c_str());

83275: <p>This Code:</p>
<pre><code>String S0 = &quot;&quot;;
String S1 = &quot;1&quot;;
String S2 = &quot;12&quot;;
String S3 = &quot;123&quot;;
String S4 = &quot;1234&quot;;
String S5 = &quot;12345&quot;;
String S6 = &quot;123456&quot;;
String S7 = &quot;1234567&quot;;
String S8 = &quot;12345678&quot;;
String S9 = &quot;123456789&quot;;
String S10 = &quot;1234567890&quot;;
String S11 = &quot;1234567890a&quot;;
String S12 = &quot;1234567890ab&quot;;
String S13 = &quot;1234567890abc&quot;;
String S14 = &quot;1234567890abcd&quot;;
String S15 = &quot;1234567890abcde&quot;;
String S16 = &quot;1234567890abcdef&quot;;
String S17 = &quot;1234567890abcdefg&quot;;
String S18 = &quot;1234567890abcdefgh&quot;;
String S19 = &quot;1234567890abcdefghi&quot;;
String S20 = &quot;1234567890abcdefghij&quot;;
Serial.printf(&quot;(0):%s\n&quot;, S0);
Serial.printf(&quot;(1):%s\n&quot;, S1);
Serial.printf(&quot;(2):%s\n&quot;, S2);
Serial.printf(&quot;(3):%s\n&quot;, S3);
Serial.printf(&quot;(4):%s\n&quot;, S4);
Serial.printf(&quot;(5):%s\n&quot;, S5);
Serial.printf(&quot;(6):%s\n&quot;, S6);
Serial.printf(&quot;(7):%s\n&quot;, S7);
Serial.printf(&quot;(8):%s\n&quot;, S8);
Serial.printf(&quot;(9):%s\n&quot;, S9);
Serial.printf(&quot;(10):%s\n&quot;, S10);
Serial.printf(&quot;(11):%s\n&quot;, S11);
Serial.printf(&quot;(12):%s\n&quot;, S12);
Serial.printf(&quot;(13):%s\n&quot;, S13);
Serial.printf(&quot;(14):%s\n&quot;, S14);
Serial.printf(&quot;(15):%s\n&quot;, S15);
Serial.printf(&quot;(16):%s\n&quot;, S16);
Serial.printf(&quot;(17):%s\n&quot;, S17);
Serial.printf(&quot;(18):%s\n&quot;, S18);
Serial.printf(&quot;(19):%s\n&quot;, S19);
Serial.printf(&quot;(20):%s\n&quot;, S20);
</code></pre>
<p>Gives This Result:</p>
<pre><code>(0):
(1):1
(2):12
(3):123
(4):1234
(5):12345
(6):123456
(7):1234567
(8):12345678
(9):123456789
(10):�H�?
(11):�^�?
(12):_�?
(13):�_�?
(14):`�?
(15):0`�?
(16):�`�?
(17):a�?
(18):@a�?
(19):pa�?
(20):�a�?
</code></pre>
<p>Any ideas??
PS: IT IS OBVIOUS that for whatever platform it is being used, it is working for short strings and not for longer strings! And it has been answered in the comments after you have closed it! So if you do not know the answer instead of closing, maybe it is better to leave it for others to answer it...</p>
 71575: <p>(Community Wiki answer assembled from the comments)</p>
<p>Noting that the standard Arduino core doesn't have a <code>Serial.printf()</code> function. The ESP32 core does.</p>
<p>You need <code>.c_str()</code> in your calls. <code>.printf()</code> is a <a href="https://en.cppreference.com/w/c/variadic" rel="nofollow noreferrer">variadic function</a> which doesn't really have access to any sort of destination type to do conversions; it relies entirely on your passing the correct format specifiers. It is just supplying the bytes to the <code>String</code> object, which is not simply a <code>const char *</code> (specified <code>%s</code>). If you're curious, the behaviour difference you're seeing is down to whether &quot;small string optimization&quot; is being used.</p>
<p>Short string optimization is where shorter strings are stored directly in the object and for longer strings it's used as pointers.</p>
<p>The suggested solution is to use: <code>Serial.printf(&quot;%s&quot;,Sxx.c_str());</code></p>
