• Login
Community
  • Login

Inserting UTF-8 Text

Scheduled Pinned Locked Moved Notepad++ & Plugin Development
4 Posts 3 Posters 378 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    Chester Fritz
    last edited by Chester Fritz Feb 26, 2021, 6:24 AM Feb 26, 2021, 6:22 AM

    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?

    E A 2 Replies Last reply Feb 26, 2021, 9:34 AM Reply Quote 0
    • E
      Ekopalypse @Chester Fritz
      last edited by Feb 26, 2021, 9:34 AM

      @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.

      1 Reply Last reply Reply Quote 1
      • A
        Alan Kilborn @Chester Fritz
        last edited by Alan Kilborn Feb 26, 2021, 1:08 PM Feb 26, 2021, 1:07 PM

        @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.

        1 Reply Last reply Reply Quote 1
        • C
          Chester Fritz
          last edited by Chester Fritz Feb 26, 2021, 6:30 PM Feb 26, 2021, 6:30 PM

          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.

          1 Reply Last reply Reply Quote 1
          2 out of 4
          • First post
            2/4
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors