Get unicode characters from a rich edit control
<p>I use this function to get a line of text from a rich edit control.   </p>

<pre><code>CString RichEditCtrlEx::getLine(int charIndex) const
{
CString retval;

int lineIndex = LineFromChar(charIndex);
ASSERT(lineIndex&gt;=0 &amp;&amp; lineIndex&lt;GetLineCount());
int sizeOfLine = LineLength(charIndex);

TCHAR* buffer = new TCHAR[sizeOfLine + 148];

ASSERT(buffer);

if (buffer) {

    memset(buffer,0,sizeOfLine + 148);
    *((int *)buffer) = sizeOfLine;

    GetLine(lineIndex, buffer);
    retval = buffer;
    delete[] buffer;
}

return retval;  
}
</code></pre>

<p>The function GetLine:</p>

<pre><code>_AFXWIN_INLINE int CEdit::GetLine(_In_ int nIndex, _Out_ LPTSTR lpszBuffer) const
{ ASSERT(::IsWindow(m_hWnd)); return (int)::SendMessage(m_hWnd, EM_GETLINE, nIndex, (LPARAM)lpszBuffer); 
</code></pre>

<p>For the most part it works perfectly. However if the text in the rich edit control contains special characters (e.g. "拿듬壴竒" ) the characters which are returned are wrong (when using the characters in the example the result is "ÿìôÒ")</p>

<p>Does the EM_GETLINE message allow these special characters? Or do I need a different approach?</p>
