FormatMessageV
CString
\n
\r\n
#include <atlstr.h> #include <iostream> CString FormatV(LPCTSTR first, ...) { va_list vaList = nullptr; CString buffer; va_start(vaList, first); buffer.FormatMessageV(first, &vaList); //this adds \r before \n va_end(vaList); return buffer; } int main() { CString text = L"\nint Fun(LPCTSTR commandLine, UINT number)\n{ Perform(commandLine,% 1); \n }"; // Notice that // it has only \n s CString formattedText = FormatV(text, 1); //formattedText has \r\n s if (formattedText.Find(L'\r', 0) != -1) std::cout << "Has CR in it!"; }
formattedText.Replace(_T("\r\n"), _T("\n"));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)