Loop through each byte from a string : each_byte « String « Ruby






Loop through each byte from a string


hexadecimal = "\x00\x01\x10\x20"
hexadecimal.each_byte { |x| puts x }

 








Related examples in the same category

1.each_byte takes a string apart byte by byte, returning the decimal value for the character at each index location.
2.Convert each decimal to its character equivalent with Integer's chr method
3.Append the output to an array
4.each_byte block logics
5.Use case to deal with special key