c++mfcrichedit-control

Detecting newline character in rich edit text control


I'm trying split some text typed into a text edit control into individual words to put them in an array.......any newline characters should be put into an array as well. The problem is I'm having trouble detecting newline characters along the way...

What is the correct way to do this?

I've tried the following:

for(int i = 0; i < text.GetLength(); i++)
{
    m_RichEditor.SetSel(0 + i, i + 2); //from start to end character
    m_RichEditor.GetSelectionCharFormat(cf);


    if(m_RichEditor.GetSelText() == "\n") {
        OutputDebugString((CString)"here");
    }

}

but this doesn't work....


Solution

  • It seems, for RichEdit 2.0, the character for newline is not "\n"....it is "\r"!