Community
    • Login

    use of Java in C++ plugin

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    2 Posts 2 Posters 2.4k 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.
    • Miso KrupickaM
      Miso Krupicka
      last edited by

      hello

      would it be possible to use JNI to provide some Java functionality to a C++ plugin? (proof of concept)
      my plugin needs to read the whole document, then do some character manipulation and write to a new document
      i am thinking about using Java StringBuilder (i am more familiar with Java then C++, also i am more familiar with Java data structures)
      do i need to do any character encoding/decoding conversions in order to get the text from scintilla control (i assume the text will be encoded/decoded in UTF-8 when it gets from Scintilla into C++ - my default setting in NPP is UTF-8)
      but Java Strings are encoded in UTF-16 internally
      what about encoding/decoding the other way back Java->C+±>Scintilla control
      is that a problem? or am i missing anything? do i need to worry about this at all?

      thanks

      1 Reply Last reply Reply Quote 0
      • dailD
        dail
        last edited by

        would it be possible to use JNI to provide some Java functionality to a C++ plugin?

        AFAIK this would certainly be possible assuming you know enough about JNI.

        do i need to do any character encoding/decoding

        Most likely. Getting the text from Scintilla just gives you a const char * to the text however it is currently set to be encoded. You’d also want to make sure any text inserted/added to Scintilla also has the proper encoding (SCI_GETCODEPAGE may be useful to you). Depending on what you are doing you can probably do this in either Java or C++ (I don’t know enough about JNI). When writing C++ plugins I’ve normally used MultiByteToWideChar() and WideCharToMultiByte().

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