1

i have a string which contains the raw-byte information of a NSData object. And i want to have a NSData object containing these bytes.

So here is my string:

<62706c69 73743030 d4010203 04050609 0a582476 65727369 6f6e5824 6f626a65 63747359 24617263 68697665 72542474 6f701200 0186a0a2 07085524 6e756c6c 554c6973 74315f10 0f4e534b 65796564 41726368 69766572 d20b0c0d 0e546e61 6d655576 6f636162 80018000 08111a23 2d32373a 4046585d 62686a00 00000000 00010100 00000000 00000f00 00000000 00000000 00000000 00006c>

and here is my approach to put it into an NSData:

NSData *newData = [text dataUsingEncoding:NSNonLossyASCIIStringEncoding];

I tried many different encoding options but none of them worked so far. This is my result:

<3c363237 30366336 39203733 37343330 33302064 34303130 32303320 30343035 30363039 20306135 38323437 36203635 37323733 36392036 66366535 38323420 36663632 36613635 20363337 34373335 39203234 36313732 36332036 38363937 36363520 37323534 32343734 20366637 30313230 30203031 38366130 61322030 37303835 35323420 36653735 36633663 20353534 63363937 33203734 33313566 31302030 66346535 33346220 36353739 36353634 20343137 32363336 38203639 37363635 37322064 32306230 63306420 30653534 36653631 20366436 35353537 36203666 36333631 36322038 30303138 30303020 30383131 31613233 20326433 32333733 61203430 34363538 35642036 32363836 61303020 30303030 30303030 20303030 31303130 30203030 30303030 30302030 30303030 66303020 30303030 30303030 20303030 30303030 30203030 30303030 30302030 30303036 633e>

Rob
  • 415,655
  • 72
  • 787
  • 1,044
Gustl007
  • 245
  • 1
  • 2
  • 12
  • 1
    Your first string looks like the `description` output of some NSData object. Of course you can convert that back to NSData (see for example http://stackoverflow.com/a/13627835/1187415). - But you should also consider to use a different representation of your original data, e.g. Base64 encoded. – Martin R Feb 08 '14 at 21:32

0 Answers0