Head scratcher on replacing hex 0D 0D 0A with 0D 1C 0D

Clovertech Forums Read Only Archives Cloverleaf Tcl Library Head scratcher on replacing hex 0D 0D 0A with 0D 1C 0D

  • Creator
    Topic
  • #52973
    Nate Kruse
    Participant

      I have an inbound file that contains many messages. At the end of each message, there is a 0D 0D 0A separating it from the next message. The receiving system that the file is eventually FTP’d to needs the ending characters of every message as 0D 1C 0D

      regsub -all — {DDD} $fileIn “D1CD” newmsg

      Any help would be greatly appreciated. Thank you!

      Nate K

    Viewing 1 reply thread
    • Author
      Replies
      • #76134
        James Cobane
        Participant

          Nate,

          You will need to use the hex nomenclature for this:

          regsub -all — {x0Dx0Dx0D} $fileIn “x0Dx1Cx0D” newmsg

          You could also use the “string map” command.

          Hope this helps.

          Jim Cobane

          Henry Ford Health

        • #76135
          Nate Kruse
          Participant

            Thank you, James. That worked perfectly! I typically don’t have to replace hex characters, so I was stuck since I couldn’t use the typical n r values for newline and carriage return. Learn something new everyday!

            Nate K

        Viewing 1 reply thread
        • The forum ‘Tcl Library’ is closed to new topics and replies.