• Login
Community
  • Login

How to see hex value of character next to cursor?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
26 Posts 6 Posters 7.7k 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.
  • P
    PeterJones @Alan Kilborn
    last edited by Aug 7, 2020, 5:46 PM

    @Alan-Kilborn said in How to see hex value of character next to cursor?:

    Perfect usage: Replace “curly double-quotes” with straight ones. :-)

    I wouldn’t call that “perfect”, since [“”] => " does it perfectly well without scripting. :-) Assuming you noticed they were curly in the first place.

    Despite that, I do think it’s a nice extension to my script. :-)

    A 1 Reply Last reply Aug 7, 2020, 5:50 PM Reply Quote 4
    • A
      Alan Kilborn @PeterJones
      last edited by Aug 7, 2020, 5:50 PM

      @PeterJones

      I guess the “curly” thing was a bit contrived… :-)

      I’ll tell you my real use case of recent origin:
      Getting rid of some invisible LTR marks in a bunch of Skype conversation logs–ugh.

      1 Reply Last reply Reply Quote 4
      • A
        Alan Kilborn
        last edited by Mar 22, 2022, 8:10 PM

        I posted an updated script for this topic, HERE.

        J 1 Reply Last reply Apr 27, 2023, 8:39 AM Reply Quote 2
        • J
          Jeff Heath @Alan Kilborn
          last edited by Apr 27, 2023, 8:39 AM

          Can someone clarify how to actually run this script? I’ve followed the installing PythonScript [Guide](link https://notepad-plus-plus.org/community/topic/17256/guide-how-to-install-the-pythonscript-plugin-on-notepad-7-6-3-7-6-4-and-above), but as I search around there are also references to installing the Python Script plug-in, but that’s not available in my version of npp (maybe because it is 64 bit?).

          Anyway, if I followed that PythonScript Guide, and have the plugins\PythonScript folder set up, how do I then run the script? I’ve also installed the NppExec plug-in, but don’t immediately see how that could be used.

          I seem to be missing something. Can anyone give me a hint?

          E P 2 Replies Last reply Apr 27, 2023, 8:53 AM Reply Quote 0
          • E
            Ekopalypse @Jeff Heath
            last edited by Ekopalypse Apr 27, 2023, 8:54 AM Apr 27, 2023, 8:53 AM

            @Jeff-Heath
            Once you have installed the PythonScript plugin, you should
            see an additional entry in the plugin menu.
            In that menu, there is a menu item called Show Console.
            Click on it, and if the console opens without reporting a problem, the installation of PS was successful.

            b247a11f-3f77-4997-b4dc-2fe06296f91f-image.png

            To create a new script, use the menu again and select New Script,
            But make sure the directory it points to is your ...plugins\Config\PythonScript\scripts\ directory.
            Give it a meaningful name and copy the code into it.
            Save it.
            Now it should appear in the list of the Scripts menu item.
            If you want it to be accessible in the PS main menu,
            you have to use the PS menu option Configuration…
            and add it to the main menu section. That’s it.
            Now you can run it by clicking on it or assigning a shortcut, etc.

            1 Reply Last reply Reply Quote 0
            • J
              Jeff Heath
              last edited by Apr 27, 2023, 8:57 AM

              I finally noticed in the Plugins Admin that the Python Script plugin (version 1.3) that I installed manually (with the link above) was listed under the “Incompatible” tab. But I was able to install it on the “Updates” tab to version 2. Now I have an element “Python Script” on the Plugins menu which allows me to create a new script, etc. So I think I can now try to progress and try a few more things.

              But why was “Python Script” not available in the Plugins Admin in the first place? All it has is “Python Indent”. I certainly don’t want to have to manually install 1.3 then do the update the next time.

              E 1 Reply Last reply Apr 27, 2023, 9:03 AM Reply Quote 0
              • E
                Ekopalypse @Jeff Heath
                last edited by Apr 27, 2023, 9:03 AM

                @Jeff-Heath

                That sounds strange, because normally you have it available.
                I’ve never had a problem installing it, and I do it this way with every new npp version. I think I’ve been doing this since 7.9.5, which is how my automated tests run.
                The only reason I can think of why it doesn’t show up in the Available tab is if npp thinks it has already found something.

                J 1 Reply Last reply Apr 27, 2023, 9:07 AM Reply Quote 0
                • J
                  Jeff Heath @Ekopalypse
                  last edited by Apr 27, 2023, 9:07 AM

                  @Ekopalypse Thanks for your feedback. I’ve got the script working now, and I’ll worry later about getting Python Script running on a new install.

                  A 1 Reply Last reply Apr 27, 2023, 11:06 AM Reply Quote 1
                  • A
                    Alan Kilborn @Jeff Heath
                    last edited by Alan Kilborn Apr 27, 2023, 11:08 AM Apr 27, 2023, 11:06 AM

                    @Jeff-Heath

                    A really good up-to-date thread for things PythonScript is HERE. The bulk of your problem might have been trying to follow old, outdated PS information. Not sure how to solve the problem of outdated info in old threads here…

                    1 Reply Last reply Reply Quote 0
                    • J
                      Jeff Heath
                      last edited by Jeff Heath Apr 27, 2023, 11:41 AM Apr 27, 2023, 11:40 AM

                      Thanks all for your input. I’ve made a few edits to produce the format I wanted for the output, and changes which I think make the code more readable (including adding a few comments). In case this is helpful for anyone else, here it is:

                      # encoding=utf-8
                      
                      def callback_sci_UPDATEUI(args):
                          # get character (as an integer) at the current position
                          c = editor.getCharAt(editor.getCurrentPos())
                          if c == 0:
                              info = 'END-OF-FILE'
                          elif c in [10,13]:
                              info = "U+{0:04X} LINE-ENDING".format(c)
                          else:
                              # not one of the special cases
                              if 1 <= c <= 255:
                                  # simple ANSI character
                                  s = unichr(c)
                              else:
                                  # more complex case, so get the text range
                                  pos = editor.getCurrentPos()
                                  pos2 = editor.positionAfter(pos)
                                  s = editor.getTextRange(pos,pos2).decode('utf-8')
                                  # handle wide ordinals https://stackoverflow.com/a/7291240/5508606
                                  if len(s) != 2:
                                      c = ord(s)
                                  else:
                                      c = 0x10000 + (ord(s[0]) - 0xD800) * 0x400 + (ord(s[1]) - 0xDC00)
                              
                              # produce desired format for the status bar
                              try:
                                  info = "U+{0:04X} '{1}'".format(c, s.encode('utf-8'))
                              except:
                                  info = "U+????"
                          
                          notepad.setStatusBar(STATUSBARSECTION.DOCTYPE, info)
                      
                      #callback_sci_UPDATEUI(None)     # per https://notepad-plus-plus.org/community/topic/17799/, want on-demand
                      editor.callback(callback_sci_UPDATEUI, [SCINTILLANOTIFICATION.UPDATEUI]) # per https://notepad-plus-plus.org/community/topic/14767/, want live
                      

                      I haven’t tested with any characters outside the BMP, but I think I transformed the code properly. Someone who works with those characters can feel free to test it…

                      A 1 Reply Last reply Apr 27, 2023, 12:19 PM Reply Quote 0
                      • A
                        Alan Kilborn @Jeff Heath
                        last edited by Apr 27, 2023, 12:19 PM

                        @Jeff-Heath

                        There is also a plugin (at least one) that can provide the functionality you seek. It’s called GotoLineCol in PluginsAdmin and it shows you this:

                        1f4be7c7-9054-4ff5-b7c9-3bbe4b82cc95-image.png

                        when your caret is next to a 💙 character.

                        1 Reply Last reply Reply Quote 0
                        • P
                          PeterJones @Jeff Heath
                          last edited by PeterJones Apr 27, 2023, 1:04 PM Apr 27, 2023, 12:55 PM

                          @Jeff-Heath said in How to see hex value of character next to cursor?:

                          I’ve followed the installing PythonScript Guide,

                          FYI: that guide from 2019 was focused on the brief time when Notepad++ had just come out of a confusing update, and not all plugins (including Python Script) were yet compatible with the new Plugins Admin method of installing plugins. PythonScript v1.5, released in Oct 2019, was the first PS version compatible with Notepad++'s Plugins Admin interface… but that means that PythonScript has been available through the default interface Since Oct 2019. You no longer need to follow that ancient guide.

                          update: sorry, apparently it wasn’t fully compatible until v1.5.1, also in October 2019; it was first listed in Plugins Admin in Notepad++ v7.8.1 – so from that point on, you don’t need to follow that outdated guide.

                          f798369e-eab4-4bb7-9851-c17db123cd8e-image.png

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