From: Brian Candler Date: 2012-07-01T06:52:15+09:00 Subject: Re: Newb on String to Hex for UDP packet ricky quirch wrote in post #1066641: > eg: Please enter last octect of IP address: user enters:123 or 7B > > i then want to include that as a hex byte in a UDP packet and send it. > > Eg: UDP = "/x00/x12/x23/(insert value in hex here)/x00/x00" > > I managed to include the value in there but the resulting UDP packet is > sending the value in asccii, > the packet looks like: 00:12:23:31:32:33:00:00 You might want to look at Array#pack >> [123].pack("C") => "{" >> [255].pack("C") => "\377" >> [192,168,1,4].pack("C*") => "\300\250\001\004" >> [0x7f000001].pack("N") => "\177\000\000\001" -- Posted via http://www.ruby-forum.com/.