Pasting hexadecimal values in ASCII as binary in hex edit mode

Pasting hexadecimal values in ASCII as binary in hex edit mode

4
NewbieNewbie
4

    Jan 21, 2016#1

    Copying text "AB CD 12 34" and pasting it as binary.

    When will this feature be available?

    I think I remember asking for this 10 years ago.

    Seriously, last time I checked, there was only one other tool that did this.

    6,603548
    Grand MasterGrand Master
    6,603548

      Jan 21, 2016#2

      So you want to copy AB CD 12 34 as text from within a text file and paste it into a binary file with 4 bytes with those hexadecimal values or paste the appropriate characters into current text file.

      Is that right? Why do wait for such a feature built-in in UltraEdit?

      This can be done with an UltraEdit script which works like a plugin or custom feature extension.

      See for example Script to get string from Windows registry value with hexadecimal values or Convert ASCII-represented hex to hex on Macros & Scripts download page which could be exactly what you need if you want the hexadecimal values pasted as characters into a text file.
      Best regards from an UC/UE/UES for Windows user from Austria

      4
      NewbieNewbie
      4

        Jan 21, 2016#3

        Why wait for UltraEdit? I'm not waiting.
        Why add a script to UltraEdit? I'm not doing that.

        I just use another tool!

        UltraEdit should have that feature built in.

        6,603548
        Grand MasterGrand Master
        6,603548

          Jan 22, 2016#4

          Why do you think that UltraEdit should have this feature built-in? Do you really think a large group of the licensed UltraEdit users need that feature?

          I don't think so. People using UltraEdit for creating/editing webpages most likely don't need that feature. Also users using UltraEdit for editing CSV files don't need this feature. Even most programmers don't need this feature in my point of view. I'm working since more than 20 years as programmer and whether I nor any of my 50 programming colleagues ever asked for a function to convert ASCII hex to binary respectively text.

          The development model used for UltraEdit by IDM Computer Solutions, Inc. is a user-driven model. If many users request a specific feature, this feature is implemented. But features being of interest just by a handful of users are just added to list of possible features for implementation. The number of users requesting this possible new feature determines if the feature request is in list at top or at bottom.

          Macros and scripts are for user customizations and extensions of UltraEdit which go beyond what is interesting for a larger group of UltraEdit users. I don't understand why you don't make use of them. Macros and scripts are ideal to extend UltraEdit with functions tailor-made for someones work.

          An UltraEdit script written by myself, or downloaded from Macros & Scripts page, or written by a helpful other UltraEdit user according to my requirements, saved to a directory of my choice, added with Scripting - Scripts without a hotkey/chord for execution by a click on this script in menu Scripting or by a double click on the script in Script List view, or with hotkey/chord for execution at any time quickly by key is preferred by many users of UltraEdit for extending UltraEdit with tailor-made features not built-in in UltraEdit. You should really think about usage of macros and scripts.

          By the way: Is the text in your post all you sent IDM 10 years ago?

          Yes, than I'm not really surprised that you don't see such a feature built-in. On reading your post I have an idea what you more or less want. But the feature description is not clear enough for writing the code. The feature description is not detailed enough for an implementation.
          Best regards from an UC/UE/UES for Windows user from Austria

          4
          NewbieNewbie
          4

            Jan 22, 2016#5

            What do you all think about the feature "Hex Insert/Delete" in "Hex Functions" menu?

            115
            Power UserPower User
            115

              Jan 22, 2016#6

              I've been a programmer for more than 35 years. It is best to use the right tool for a job. Text editors, even advanced text editors like UltraEdit, are not the right tool for editing binary files. The correct tool is a hex editor, of which there are many out there, including open source (free license) and commercial. There are command line and GUI versions. Take a look on Wikipedia using the search string "comparison of hex editors" to see what features are provided for many of the most popular programs.


              So no, I do not support adding this functionality to UltraEdit, any more than I would want a drawing widget added. Use a hammer for nails and use a wrench for nuts and bolts.

              6,603548
              Grand MasterGrand Master
              6,603548

                Jan 23, 2016#7

                ip74 wrote:What do you all think about the feature "Hex Insert/Delete" in "Hex Functions" menu?
                Not much. Hex Insert/Delete works as designed and described in help of UltraEdit.

                But I try once again to encourage you using an UltraEdit script now after knowing better what you want.

                I suggest a solution which replaces command Paste by an enhanced version customized for your needs.
                1. Open a new file in UltraEdit with Ctrl+N and make sure that the file is an ASCII/ANSI file with DOS line terminators.
                  See indications on status bar at bottom of UltraEdit main window and use the appropriate commands in File - Conversions in case of having a different encoding or different line termination type configured for new files.
                2. Copy & paste following script code into the new file.

                  Code: Select all

                  // Is any file opened in UltraEdit / UEStudio?
                  if (UltraEdit.document.length > 0)
                  {
                     // Is active file opened in hex edit mode?
                     if (UltraEdit.activeDocument.isHexModeOn())
                     {
                        // Does the active clipboard contain only hexadecimal values in
                        // ASCII with always exactly two hexadecimal characters per byte
                        // and without or with whitespaces around them?
                        if (UltraEdit.clipboardContent.search(/^\s*(?:[0-9A-Fa-f]{2}\s*)+$/) == 0)
                        {
                           // Get the hexadecimal values in ASCII without the whitespaces.
                           var sHexAscii = UltraEdit.clipboardContent.replace(/\s+/g,"");
                           // Clear the clipboard.
                           UltraEdit.clearClipboard();
                           // Write to clipboard the bytes according to hexadecimal values.
                           for (var nCharIndex = 0; nCharIndex < sHexAscii.length; nCharIndex += 2)
                           {
                              var nByteValue = parseInt(sHexAscii.substr(nCharIndex,2),16);
                              UltraEdit.clipboardContent += String.fromCharCode(nByteValue);
                           }
                        }
                     }
                     // Execute paste command independent on editing mode and
                     // clipboard content was modified by the script at all.
                     UltraEdit.activeDocument.paste();
                  }
                  
                  You can remove all comment lines starting with // after 0 or more spaces to make execution a little bit faster.
                3. Using command File - Save As and store the file for example with name SmartHexPaste.js into a directory of your choice, for example %APPDATA%\IDMComp\UltraEdit\scripts whereby subdirectory scripts must be most likely created first within Save As dialog.
                4. Close the script file and click on menu item Scripts in menu Scripting.
                5. Click on button Add, browse to just saved script file, select it, enter in field Description for example
                  Pastes hexadecimal values in ASCII as binary in hex edit mode
                  (optional, not required) and click on button Open.
                6. Double click with primary mouse button into cell of column Hotkey in row of just added script, press Ctrl+V and then click into any other cell with primary mouse button to assign this hotkey to the script. Click on button OK to save modified list and close the Scripts dialog.
                7. Although it is not really necessary, it is best to open now Advanced - Configuration - Key Mapping, navigate in list of Commands to the command EditPaste, and click on button Remove to remove Ctrl+V as hotkey for this command.
                8. Click next on configuration tree on Scripting and uncheck setting Show status information in output window which disables overwriting current contents of active output window by status and error information output usually to output window on running a script. Uncheck also setting Show cancel dialog in same configuration dialog.
                9. Close the configuration dialog with a click on button OK to take over changed key mapping and scripting configuration settings which are saved on next exit of UltraEdit also into uedit*.uek and uedit*.ini file (or Windows registry).
                Whenever you press now Ctrl+V, the script is executed resulting in doing the paste from clipboard in most cases. There is no difference to built-in paste for a paste in text edit mode in standard or column editing mode with insert or overstrike mode and with or without having a selection as the script executes in those modes simply the command Paste. Also Ctrl+V in hex edit mode is in most cases just a simple Paste.

                But if
                1. hex edit mode is enabled for active file

                  AND
                2. the active clipboard contains an ASCII text with hexadecimal values without or with whitespaces (space, tab, carriage return, line-feed, ...) between and/or around the ASCII representation of the hexadecimal values
                the script modifies content of active clipboard before executing the paste. The ASCII text with the hexadecimal values are converted to bytes in clipboard before doing the paste.

                The clipboard content is not modified if both conditions are not true for example if clipboard contains B CD 12 34 or AB CD 12 3 or other characters than whitespaces, digits and the letters A-F in any case.

                It is of course also possible to assign a chord (multi-key assignment) or a different hotkey than Ctrl+V to the script if you don't want to replace standard command Paste by the smart hex paste via the script.

                Here is a variant of above script without comments which restores original clipboard content after binary paste in hex edit mode.

                Code: Select all

                if (UltraEdit.document.length > 0)
                {
                   var sClipboardContent = "";
                   if (UltraEdit.activeDocument.isHexModeOn())
                   {
                      if (UltraEdit.clipboardContent.search(/^\s*(?:[0-9A-Fa-f]{2}\s*)+$/) == 0)
                      {
                         sClipboardContent = UltraEdit.clipboardContent;
                         var sHexAscii = UltraEdit.clipboardContent.replace(/\s+/g,"");
                         UltraEdit.clearClipboard();
                         for (var nCharIndex = 0; nCharIndex < sHexAscii.length; nCharIndex += 2)
                         {
                            var nByteValue = parseInt(sHexAscii.substr(nCharIndex,2),16);
                            UltraEdit.clipboardContent += String.fromCharCode(nByteValue);
                         }
                      }
                   }
                   UltraEdit.activeDocument.paste();
                   if (sClipboardContent.length) UltraEdit.clipboardContent = sClipboardContent;
                }
                
                Both scripts require UltraEdit for Windows >= 14.20 or UEStudio >= v9.00.
                Best regards from an UC/UE/UES for Windows user from Austria

                4
                NewbieNewbie
                4

                  Jan 25, 2016#8

                  I'm not looking for scripts... or encouragements to do otherwise. Is this the right forum?

                  This feature would be in my opinion the same or higher applicability and usefulness than "Hex Insert/Delete"

                  UltraEdit is one of the many software we have a site license with because of its swiss army knife approach, more than useful to our multiple teams. In my opinion there is nothing that compares to it, it's on its own league.

                  Nevertheless, I think they dropped the ball in the binary editing realm.

                  115
                  Power UserPower User
                  115

                    Jan 25, 2016#9

                    IDM does not have a vast programming team. I would much rather that IDM work on things that affect the majority of the users, not a tiny fraction who refuse to use scripts or purpose-designed tools.

                    79
                    Advanced UserAdvanced User
                    79

                      Jan 26, 2016#10

                      ip74 wrote:Is this the right forum?
                      Probably not - IDM doesn't regularly monitor this forum; it's officially a "user-to-user" forum. I'd suggest that you send a message to IDM's support email address and make your case directly to them.