diff --git a/include/wx/html/winpars.h b/include/wx/html/winpars.h
index a6ebf18283..b7da33c93a 100644
--- a/include/wx/html/winpars.h
+++ b/include/wx/html/winpars.h
@@ -161,7 +161,7 @@ protected:
virtual void AddText(const wxChar* txt);
private:
- void FlushWordBuf(wxChar *temp, int& templen);
+ void FlushWordBuf(wxChar *temp, int& templen, wxChar nbsp);
void AddWord(wxHtmlWordCell *c);
void AddWord(const wxString& word);
void AddPreBlock(const wxString& text);
diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp
index 331709a4b6..785e76cf4b 100644
--- a/src/html/winpars.cpp
+++ b/src/html/winpars.cpp
@@ -496,7 +496,7 @@ void wxHtmlWinParser::AddText(const wxChar* txt)
while (i < lng)
{
x = 0;
- wxChar d = txt[i];
+ const wxChar d = temp[templen++] = txt[i];
if ((d == wxT('\n')) || (d == wxT('\r')) || (d == wxT(' ')) || (d == wxT('\t')))
{
i++, x++;
@@ -505,22 +505,17 @@ void wxHtmlWinParser::AddText(const wxChar* txt)
}
else i++;
- if ( d == nbsp )
- d = wxT(' ');
-
- temp[templen++] = d;
-
if (x)
{
temp[templen-1] = wxT(' ');
- FlushWordBuf(temp, templen);
+ FlushWordBuf(temp, templen, nbsp);
m_tmpLastWasSpace = true;
}
}
if (templen && (templen > 1 || temp[0] != wxT(' ')))
{
- FlushWordBuf(temp, templen);
+ FlushWordBuf(temp, templen, nbsp);
m_tmpLastWasSpace = false;
}
}
@@ -547,10 +542,16 @@ void wxHtmlWinParser::AddText(const wxChar* txt)
}
}
-void wxHtmlWinParser::FlushWordBuf(wxChar *buf, int& len)
+void wxHtmlWinParser::FlushWordBuf(wxChar *buf, int& len, wxChar nbsp)
{
buf[len] = 0;
+ for ( int i = 0; i < len; i++ )
+ {
+ if ( buf[i] == nbsp )
+ buf[i] = ' ';
+ }
+
#if !wxUSE_UNICODE
if (m_EncConv)
m_EncConv->Convert(buf);