[Qt-interest] Converting an integer array to a binary string of unsigned 8-bit integers.

Thiago Macieira thiago at kde.org
Wed Feb 9 12:27:57 CET 2011


Em quarta-feira, 9 de fevereiro de 2011, às 16:17:36, Plato P.B. escreveu:
> Hi,
> I am trying to convert a line of code from ruby to Qt C++.
> KEY = %w(30 81 9F 30 0D 06 09 2A 86 48 86 F7 0D 01 01 01 05 00 03 81 8D
> 00).map{|s| s.hex}.pack('C*')
> 
> The ruby code is doing this
> 
>    1. Create an array of strings, ["30", "81", "9F", ... "8D", "00" ].
>    2. Convert each hexadecimal string in the array to an integer: [48, 129,
>    159, ... 141, 0]
>    3. Use Array#pack
> <http://ruby-doc.org/core/classes/Array.html#M000206>to turn the array
> into a binary string of unsigned 8-bit integers.
> 
> Somebody pls help me. I am completely lost here! o.O

uint8_t array[] = { 0x30, 0x81, 0x9f, ... 0x8d, 0 };

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110209/31c041d4/attachment.bin 


More information about the Qt-interest-old mailing list