mirror of
https://github.com/reactos/wine.git
synced 2024-11-24 12:20:07 +00:00
riched20: Added support for UTF8 BOM stream.
This commit is contained in:
parent
cb082b9079
commit
cb8c500ee6
@ -283,9 +283,10 @@ static ME_TextBuffer *ME_MakeText(void) {
|
||||
|
||||
static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStream *stream, ME_Style *style)
|
||||
{
|
||||
WCHAR wszText[STREAMIN_BUFFER_SIZE+1];
|
||||
WCHAR *pText;
|
||||
LRESULT total_bytes_read = 0;
|
||||
BOOL is_read = FALSE;
|
||||
static const char bom_utf8[] = {0xEF, 0xBB, 0xBF};
|
||||
|
||||
TRACE("%08x %p\n", dwFormat, stream);
|
||||
|
||||
@ -304,8 +305,23 @@ static LRESULT ME_StreamInText(ME_TextEditor *editor, DWORD dwFormat, ME_InStrea
|
||||
|
||||
if (!(dwFormat & SF_UNICODE))
|
||||
{
|
||||
/* FIXME? this is doomed to fail on true MBCS like UTF-8, luckily they're unlikely to be used as CP_ACP */
|
||||
nWideChars = MultiByteToWideChar(CP_ACP, 0, stream->buffer, stream->dwSize, wszText, STREAMIN_BUFFER_SIZE);
|
||||
WCHAR wszText[STREAMIN_BUFFER_SIZE+1];
|
||||
char * buf = stream->buffer;
|
||||
DWORD size = stream->dwSize;
|
||||
DWORD cp = CP_ACP;
|
||||
|
||||
if (!is_read)
|
||||
{
|
||||
is_read = TRUE;
|
||||
if (stream->dwSize >= 3 && !memcmp(stream->buffer, bom_utf8, 3))
|
||||
{
|
||||
cp = CP_UTF8;
|
||||
buf += 3;
|
||||
size -= 3;
|
||||
}
|
||||
}
|
||||
|
||||
nWideChars = MultiByteToWideChar(cp, 0, buf, size, wszText, STREAMIN_BUFFER_SIZE);
|
||||
pText = wszText;
|
||||
}
|
||||
else
|
||||
|
@ -5120,10 +5120,10 @@ static void test_EM_STREAMIN(void)
|
||||
ok(result == 18, "got %ld, expected %d\n", result, 18);
|
||||
|
||||
result = SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
|
||||
todo_wine ok(result == 15,
|
||||
ok(result == 15,
|
||||
"EM_STREAMIN: Test UTF8WithBOM returned %ld, expected 15\n", result);
|
||||
result = strcmp (buffer,"TestUTF8WithBOM");
|
||||
todo_wine ok(result == 0,
|
||||
ok(result == 0,
|
||||
"EM_STREAMIN: Test UTF8WithBOM set wrong text: Result: %s\n",buffer);
|
||||
ok(es.dwError == 0, "EM_STREAMIN: Test UTF8WithBOM set error %d, expected %d\n", es.dwError, 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user