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

Plato P.B. platodreams at gmail.com
Wed Feb 9 11:47:36 CET 2011


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

-- 






*Thanks & Regards,*

Plato P.B.
obscurant1st.biz/blog
coolfacts.in

B'Lore.  ( +919844882641)
Kerala.  ( +919037036661)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110209/ef10fca4/attachment.html 


More information about the Qt-interest-old mailing list