Menu

notepad.runMenuCommand("Encoding", "Convert to UTF-8-BOM") is language dependent

Help
2021-02-14
2021-02-27
  • Christian M

    Christian M - 2021-02-14

    When Notepad++ language is set to something other than English:
    notepad.runMenuCommand("Encoding", "Convert to UTF-8")
    Will not be found, well that's to be expected but it seems the enum:
    notepad.menuCommand(MENUCOMMAND.FORMAT_CONV2_UTF_8)
    Converts to UTF8 with BOM and I can't find a version without BOM.
    It be nice to have both enums to convert to UTF8 with and without BOM.

    I recently discovered this little plugin and I'm very excited to all the things I'm going to be able to automate from now on ^^ Thank you so much.

     

    Last edit: Christian M 2021-02-27
    • Sasumner

      Sasumner - 2021-02-15

      Not 100% certain, but perhaps MENUCOMMAND.FORMAT_CONV2_AS_UTF_8

       
  • Christian M

    Christian M - 2021-02-27

    That was it, to summarize:

    • MENUCOMMAND.FORMAT_AS_UTF_8 -> to UTF8 without BOM
    • MENUCOMMAND.FORMAT_CONV2_AS_UTF_8 -> to UTF8 without BOM
    • MENUCOMMAND.FORMAT_CONV2_UTF_8 -> to UTF8 with BOM

    Thanks!

    Side note:
    notepad.runMenuCommand("Encoding", "Convert to UTF-8")
    will convert to UTF8 without BOM
    notepad.runMenuCommand("Encoding", "Convert to UTF-8-BOM")
    will convert with BOM

    But it only works when Notepad++ language is set to English

     

    Last edit: Christian M 2021-02-27
    • Sasumner

      Sasumner - 2021-02-27

      Regarding "English"...for whatever localization you're using, can't you just replace the strings with whatever are appropriate for the language, and have it work?

       
  • Christian M

    Christian M - 2021-02-27

    Well for certain languages it's really hard to guess what character coding where used to represent the string in the menu. But just for giggles I challenged myself and tried, after failing a few times to infer from the menu what it was, and when I was about to give up, I had the idea to look up the raw translation in xml:
    https://github.com/notepad-plus-plus/notepad-plus-plus/tree/master/PowerEditor/installer/nativeLang

    My language is Japanese so the corresponding entries in the xml are:

    <Item menuId="encoding" name="エンコード(&amp;N)"/>
    <Item id="45010" name="UTF-8 に変換"/>
    

    Which actually translates to:
    notepad.runMenuCommand("エンコード(N)", "UTF-8 に変換")

    What a journey XD

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.