#include "crlf.hh" namespace pEp { std::string operator""_CRLF(const char* str, size_t length) { static const std::string CRLF{ "\r\n" }; std::string ret; ret.reserve(length + ((length + 29) / 30) + 2); // rough guess for average line length of 30. const char* end = str + length; // N.B.: Loop could be more optimized, but not necessary because it is only used for string literals. for (; str != end; ++str) { if (*str == '\n') ret += CRLF; else ret += *str; } return ret; } } // end of namespace pEp