Arduino trim: does it remove the \n as well?
The source for the trim() function is in WString.cpp.

void String::trim(void)
{
    if (!buffer || len == 0) return;
    char *begin = buffer;
    while (isspace(*begin)) begin++;
    char *end = buffer + len - 1;
    while (isspace(*end) &amp;&amp; end &gt;= begin) end--;
    len = end + 1 - begin;
    if (begin &gt; buffer) memcpy(buffer, begin, len);
    buffer[len] = 0;
}


We can see it uses the isspace() function, but where's that function defined? WString.cpp only #includes WString.h, so we go there.

In WString.h, we can see it includes ctype.h. Time to go to the C++ Reference, which tells us that yes, \n is a "space" according to isspace(), so it is trimmed.

(note that isspace() is affected by localization settings. I'm not sure what the localization settings are when compiling for Arduino)