Uploaded image for project: 'Swift'
  1. Swift
  2. SR-2514

Add a "hex dump" method to `Data`

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Foundation
    • Labels:
      None

      Description

      There should be a way to get the contents of a Data object in hexadecimal form.
      The description methods do not provide that, as it was the case with NSData:

      let data = Data(bytes: [1, 2, 3])
      print(data) // 3 bytes
      print(data.debugDescription) // 3 bytes
      

      Of course I can cast to NSData

      print(data as NSData) // <010203>
      

      but it would be nice to have a "native" method. Suggestions:

      • description returns a hex dump, or
      • debugDescription returns a hex dump, or
      • a new hexEncodedString method, similar to the existing Base64 methods.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              martin Martin
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: