#1072 Text encoding bug that start from a WndProc call

Scintilla (796)

All start from a call to ScintillaWin::SWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, sptr_t lParam) in ScintillaWin.cxx
Here is a call stack :
Scintilla\win32\ScintillaWin.cxx(2750) : iMessage == WM_SETTEXT
Scintilla\win32\ScintillaWin.cxx(619) : iMessage = SciMessageFromEM(iMessage); iMessage move to SCI_SETTEXT
Scintilla\src\ScintillaBase.cxx(884) :
Scintilla\src\Editor.cxx(6789) : CharPtrFromSPtr(lParam)

Here lParam contain a string - for example "test" - but with such encoding that when we cast it in char*, each character is encoded on two bytes:
't' '\0' 'e' '\0' 's' '\0' 't' '\0'
So we got the probleme here when we call strlen on it:
Scintilla\src\Document.cxx(844) : return InsertString(position, s, strlen(s));
It gives a size of 1 and it truncate the string.


  • Neil Hodgson

    Neil Hodgson - 2010-12-03
    • assigned_to: nobody --> nyamatongwe
    • priority: 5 --> 3
  • Neil Hodgson

    Neil Hodgson - 2010-12-03

    Scintilla accepts strings in the UTF-8 encoding, not UTF-16.

    SCI_SETTEXT should be used rather than WM_SETTEXT. WM_SETTEXT was only included to have some compatibility with other edit controls when Scintilla was starting and only ever supported narrow strings.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks