Inserting UTF-8 Text



  • I am trying to create a plugin for inserting mathematical symbols for my mathematics documentation.
    I have used the following to accomplish this:
    SendMessageW(nppData._scintillaMainHandle, SCI_REPLACESEL, NULL,(LPARAM)text)

    However, after executing this command, the entire document view is temporarily changed to ANSI, causing my newly inserted character, as well as other UTF-8 characters to display incorrectly. If I change tabs, then return back to this one, the file view is reverted back to the default UTF-8 and the characters display correctly. I have tried various approaches to fixing this such as SCI_SETCODEPAGE with SC_CP_UTF8 as well as using WM_PAINT to no avail.

    Is there a way to fix this issue?



  • @Chester-Fritz

    I have not had such a problem yet.
    Could you give us an example of the text to be inserted and a document content so that it can be understood?
    Preferably as minimal as possible.



  • @Chester-Fritz said in Inserting UTF-8 Text:

    SendMessageW(nppData._scintillaMainHandle, SCI_REPLACESEL, NULL,(LPARAM)text)

    This seems to be an extreme route to go to, to do this.
    Curious why you would try it this way – is there some advantage?
    I agree with @Ekopalypse that some more info about your workflow would definitely help.

    Perhaps THIS THREAD is of some interest.



  • I managed to solve the issue this morning after reviewing the source to the mime tools plugin.

    The following lines of code resulted in the data being displayed correctly.
    SendMessageW(nppData._scintillaMainHandle, SCI_TARGETFROMSELECTION, 0, 0);
    SendMessageW(nppData._scintillaMainHandle, SCI_REPLACETARGET, len, (LPARAM)text);

    Thank you for the assistance.


Log in to reply