Community
    • Login

    Is there a serious reason why a "user-defined language" cannot specify the encoding?

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    2 Posts 2 Posters 59 Views 2 Watching
    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.
    • S Offline
      SMD40470
      last edited by

      I frequently use Notepad++ to edit source code for a very old target system (a PCS) that strictly requires the “OEM-US” character encoding. Some time ago, I created a “User Defined Language” (UDL) for this purpose, and (almost) everything works perfectly. However, I have to manually switch the automatically detected encoding to “OEM-US” every time. It would be great if there were an option in the UDL XML file to specify a particular character encoding so that it is applied automatically when using the UDL.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @SMD40470
        last edited by PeterJones

        @SMD40470 ,

        I think the most likely reason (whether or not you think it’s “serious” enough) is that no one has asked for that feature, and the developer didn’t think of it himself yet.

        If it was just a UDL issue, I would probably say, “You should put in the feature request, but unfortunately, there have been no new features in UDL for over a decade, with a lot of really good feature requests that would be more fundamental to making UDL work better, so it’s doubtful it would be implemented any time soon.”

        However, based on this Issue about NFO files and OEM-US/CP437 encoding, it looks like there might be other people interested, even in non-UDL circumstances. So I wonder if the better feature request might be the more generic request, something like [FEATURE REQUEST] Allow setting preferred encoding on a per-language basis.

        However, there does currently exist a workaround: the AutoCodepage plugin can be used to set default encoding on a per-extension basis. While it might be nice to have it built in, the plugin currently provides the feature. Steps to get it to work:

        • Have a UDL. In my example, I call it MyUDL and I give it the Ext.: smd, so all files ending in .smd will be treated as that UDL. (I picked smd from the letters in your username)
        • Install the plugin
        • Plugins > AutoCodepage > Settings
          • Set Group Name = MyUDL
          • Set Code page to start = OEM 437: US
          • Leave Expected language blank (because that dropdown doesn’t include UDL in the list)
          • Click the + button under the left panel
          • make sure MyUDL is highlighted in the upper left panel of the dialog
          • Set New filename extension(s) = SMD
            • whether you type in lowercase or uppercase, it ends up uppercase
            • the plugin automatically adds the . prefix when you + the extension
            • you could type another extension and + add it if your UDL has multiple possible extensions
          • Click the + button under the right panel
          • The dialog should look like:
            5713f8fa-39a7-4597-b1bf-dc5da4e15e3b-image.jpeg
          • Close the dialog
          • side notes:
            • It took me a few times to figure out the right sequence, because the plugin’s documentation is a bit sparse, which is why I was explicit as to the right order.
            • If you want to add another group – like an MS-DOS NFO group with the same codepage, but defaulting to the NFO language – you would have to follow similar steps of typing the name, setting the encoding and language, then doing the + – even though it looks like you are editing the MyUDL, as soon as you click + instead of Modify, it will create the new entry instead of modifying the old entry; you then make sure the new entry is selected, and add NFO to its extension list.
        • Create a new file, and immediate right-click the tab and name it blah.smd
          • Notepad++ will automatically apply the UDL, since the UDL extension is set to smd
          • AutoCodepage will automatically apply the OEM-US encoding
        • Open an existing blah.smd file
          • Notepad++ will automatically apply the UDL, since the UDL extension is set to smd
          • AutoCodepage will automatically apply the OEM-US encoding

        The nice thing about this plugin is that it applies that encoding when you first name, or save-and-name a file, and when you open the file from disk.

        I believe this should meet your needs, even if no one ever requests or implements the feature in native Notepad++.

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors