Unicode工程中,使用RichEdit20W,当在控件中随意输入几行字符后,取得一行:
WCHAR buf[256];
memset(buf,0,512);
this->GetLine(lineIdx,buf,255);
CString strSentence = buf;
取到的文本后面经常跟着很多乱码,LineLength函数得到的长度值也不正确。试了一下与字体设置无关,而且有的系统下正常有的不行。真是古怪,哪位帮解答,谢谢!

解决方案 »

  1.   

    使用getline必须自己在后面添加一个0,getline是不会自动添加的。
      

  2.   

    ResCall this function to retrieve a line of text from this CRichEditCtrl object. The copied line does not contain a terminating null character.Note   Because the first word of the buffer stores the number of characters to be copied, make sure that your buffer is at least 4 bytes long.For more information, seeEM_GETLINE in the Win32 documentation.
      

  3.   

    this->GetLine(lineIdx,buf,255);
    看他返回值是不是255,如果是需要加大缓冲区大小
      

  4.   

    删除MSDN的下场,多谢各位,结贴。