Getting encoding in x64 plugin

  • Hi,

    I’m trying to get the current document encoding by using NPP message NPPM_GETBUFFERENCODING, but I cannot make it work. My code is following:

    int bufferid = ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTBUFFERID, 0, 0);
    LRESULT res = ::SendMessage(nppData._nppHandle, NPPM_GETBUFFERENCODING, bufferid, 0);

    The code compiles well but on runtime, NPP crashes with following error, pointing on second line of above code (tested by running NPP and plugin in debug mode):

    Exception levée à 0x00007FF7929A6061 dans notepad++.exe : 0xC0000005 : Violation d’accès lors de la lecture de l’emplacement 0x000000003AC89F1C.
    Le programme ‘[2312] notepad++.exe’ s’est arrêté avec le code 0 (0x0).

    Did anyone already experienced and solved this ?

  • Try making bufferid an LRESULT instead of an int. It may be that it is getting downcasted (though you should get a compiler warning).

  • Hi @dail, thanks for your answer, it solved my issue :D