how convert binary 3 bytes strings into hex data

how convert binary 3 bytes strings into hex data

2
NewbieNewbie
2

    Mar 09, 2006#1

    Hello

    I have a problem is that I have to do a large file containing binary data wich should be converted into hex data.

    Example of a conversion result
    00110111 10101000 00000111
    00110111 10100000 00011111
    into
    0x37A807
    0x37A01F
    I tried to use the number converter. I can't call the tool (isn't recorded by a quick macro) or do a search and replace in a rang from 0- 255

    :roll:

    6,686585
    Grand MasterGrand Master
    6,686585

      Mar 09, 2006#2

      Not very difficult. The binary values has to be split into groups of 4 bits (nibbles). Then convert all 16 possible binary nibble values into their hex equivalents. Add a 0x at the beginning of every line and remove all spaces.

      Enable the macro property Continue if a Find with Replace not found for this macro.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Find RegExp "^([01][01][01][01]^)"
      Replace All " ^1 "
      Find "0000"
      Replace All "0"
      Find "0001"
      Replace All "1"
      Find "0010"
      Replace All "2"
      Find "0011"
      Replace All "3"
      Find "0100"
      Replace All "4"
      Find "0101"
      Replace All "5"
      Find "0110"
      Replace All "6"
      Find "0111"
      Replace All "7"
      Find "1000"
      Replace All "8"
      Find "1001"
      Replace All "9"
      Find "1010"
      Replace All "A"
      Find "1011"
      Replace All "B"
      Find "1100"
      Replace All "C"
      Find "1101"
      Replace All "D"
      Find "1110"
      Replace All "E"
      Find "1111"
      Replace All "F"
      Find RegExp "% +"
      Replace All "0x"
      Find RegExp " +"
      Replace All ""
      UnixReOn

      Remove the last red command, if you use regular expression in UltraEdit style by default instead of Unix style.
      For UltraEdit v11.10c and lower see Advanced - Configuration - Find - Unix style Regular Expressions.
      For UltraEdit v11.20 and higher see Advanced - Configuration - Searching - Unix style Regular Expressions.
      Macro commands UnixReOn/UnixReOff modifies this setting.
      Best regards from an UC/UE/UES for Windows user from Austria

      2
      NewbieNewbie
      2

        Mar 10, 2006#3

        thanx thanx thanx another good example to learn from :wink:

        dennis netherlands

        3
        NewbieNewbie
        3

          Mar 10, 2006#4

          Hello, Mofi

          Would you please tell me why you have to add the following causes in your macro?

          Find RegExp "^([01][01][01][01]^)"
          Replace All " ^1 "

          thanks a lot in advance.

          6,686585
          Grand MasterGrand Master
          6,686585

            Mar 10, 2006#5

            Hello tanenbaum!

            Let us look at binary code 10001000. The regular expression replace splits the 8 bits up into 2 groups of 4 bits. So you get space1000spacespace1000space. How many spaces are added is not important here, because they are all removed with the last regular expression. But why is this split necessary?

            We have to think about what would happen without splitting the binary values into nibbles.

            The first replace searches for 0000 which would have no effect on 10001000.

            The second replaces searches for 0001 and replaces it with a single 1. Without splitting the 8 bits into 2 nibbles this would result in a conversion of 10001000 into 11000.

            The next replaces will convert it further from 11000 to 18.

            You see without splitting you will get 18 instead of 88.
            Best regards from an UC/UE/UES for Windows user from Austria