I am generating text (standard alpha chars only) into a std::string
converting to a char[]
-array to wchar
and assigning it to a TMemo box... (c++ Builder.) At another point (function) I am reading (what should be the same) text from a file and loading it into a std::string
converting to a char[]
-array to a wchar
and again loading the text into the TMemo box. Everything works.
When creating the string it loads very quickly into the TMemo box using the function below... However when loading the string from the text file it suddenly slows down to a crawl, about 10 times slower or worse even though the code for both is the same excluding the initial read or create of the string...
What's more is that the only slow part of this function is this line
Form1->Memo1->Text = uni_out;
If I comment out this line there is no slowdown...
Any thoughts as to why?
void print_txt(char asc_in[])
{
wchar_t *uni_out = new wchar_t[ strlen(asc_in) + 1 ]; // + 1 for term 0
std::mbstowcs(uni_out, asc_in, strlen(asc_in) + 1);
Form1->Memo1->Text = uni_out;
delete[] uni_out;
}
EDIT:
I just noticed that when the text file is read it's formatting is gone... The \r\n creates new lines when opening the file with notepad but when opening with std::ifstream, std::getline the formatting is gone completely, and while I have not yet confirmed this I think it is reading the entire file in as one line.