Removed junk from UTF-8 RTF output.
This commit is contained in:
parent
d11466c161
commit
d291f3cd77
|
@ -567,7 +567,7 @@ ME_StreamOutRTFText(ME_TextEditor *editor, WCHAR *text, LONG nChars)
|
||||||
{
|
{
|
||||||
char buffer[STREAMOUT_BUFFER_SIZE];
|
char buffer[STREAMOUT_BUFFER_SIZE];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
int fit, i;
|
int fit, nBytes, i;
|
||||||
|
|
||||||
if (nChars == -1)
|
if (nChars == -1)
|
||||||
nChars = lstrlenW(text);
|
nChars = lstrlenW(text);
|
||||||
|
@ -577,18 +577,18 @@ ME_StreamOutRTFText(ME_TextEditor *editor, WCHAR *text, LONG nChars)
|
||||||
if (editor->pStream->nDefaultCodePage == CP_UTF8) {
|
if (editor->pStream->nDefaultCodePage == CP_UTF8) {
|
||||||
/* 6 is the maximum character length in UTF-8 */
|
/* 6 is the maximum character length in UTF-8 */
|
||||||
fit = min(nChars, STREAMOUT_BUFFER_SIZE / 6);
|
fit = min(nChars, STREAMOUT_BUFFER_SIZE / 6);
|
||||||
WideCharToMultiByte(CP_UTF8, 0, text, fit, buffer, STREAMOUT_BUFFER_SIZE,
|
nBytes = WideCharToMultiByte(CP_UTF8, 0, text, fit, buffer,
|
||||||
NULL, NULL);
|
STREAMOUT_BUFFER_SIZE, NULL, NULL);
|
||||||
nChars -= fit;
|
nChars -= fit;
|
||||||
text += fit;
|
text += fit;
|
||||||
for (i = 0; buffer[i]; i++)
|
for (i = 0; i < nBytes; i++)
|
||||||
if (buffer[i] == '{' || buffer[i] == '}' || buffer[i] == '\\') {
|
if (buffer[i] == '{' || buffer[i] == '}' || buffer[i] == '\\') {
|
||||||
if (!ME_StreamOutPrint(editor, "%.*s\\", i - pos, buffer + pos))
|
if (!ME_StreamOutPrint(editor, "%.*s\\", i - pos, buffer + pos))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
pos = i;
|
pos = i;
|
||||||
}
|
}
|
||||||
if (!pos)
|
if (!pos)
|
||||||
if (!ME_StreamOutPrint(editor, "%s", buffer + pos))
|
if (!ME_StreamOutMove(editor, buffer + pos, nBytes - pos))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
} else if (*text < 128) {
|
} else if (*text < 128) {
|
||||||
|
@ -599,7 +599,6 @@ ME_StreamOutRTFText(ME_TextEditor *editor, WCHAR *text, LONG nChars)
|
||||||
} else {
|
} else {
|
||||||
BOOL unknown = FALSE;
|
BOOL unknown = FALSE;
|
||||||
BYTE letter[3];
|
BYTE letter[3];
|
||||||
int nBytes, i;
|
|
||||||
|
|
||||||
/* FIXME: In the MS docs for WideCharToMultiByte there is a big list of
|
/* FIXME: In the MS docs for WideCharToMultiByte there is a big list of
|
||||||
* codepages including CP_SYMBOL for which the last parameter must be set
|
* codepages including CP_SYMBOL for which the last parameter must be set
|
||||||
|
|
Loading…
Reference in New Issue