I want to take the value as:
ff0000
and turn it into a byte array containing these hexadecimal values:
\xff\x00\x00
I do not understand how to do this using str.unpack
str.unpack
"ff0000".scan(/../).map { |match| match.hex } #=> [255, 0, 0]
or
("ff0000".scan(/../).map { |match| match.hex }).pack('C*') #=> "\377\000\000"
Depending on what format you want.
I'm not sure unpacking can do this. Try instead:
"ff0000".gsub(/../) { |match| match.hex.chr }
Source: https://habr.com/ru/post/1720207/More articles:PDO in PHP how to improve this PDO mysql code - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1720203/repository-pattern-and-linq-to-sql&usg=ALkJrhhh0-R53kUtZ-qV0TrJ9ad48yo_UgExceeding maximum latency in a Java web application using Oracle DB - javaЕдиный вход с помощью Joomla и Flash - authenticationRendering WPF objects as graphics in ASP.NET - asp.netHow do you create a single page interface in ASP.NET MVC? - ajaxWhy can't a dictionary object be XmlSerialized in C #? - dictionaryIn JPA and Spring, can I create a save unit on the fly? - springДизайн плагина WPF GUI. Мне нужна обратная связь - designASP.NET MVC - restarting FormMethod.Get querystring? - query-stringAll Articles