Ruby send string variable as hex

How am I to express variable as hex to send like-

write("\x#{a}") => 0x00

Trying to include received string variable into command string of raw data and passed to com port like -


In Ruby



The String#to_i function takes a base argument, which default to ten - but you can pass in sixteen instead. That'll get you the number you want as a number, rather than a string. From there, you can use the Integer#chr function to get the value you want - a string containing the character with the binary value represented by the original string.

Need Your Help

NLOG, Log to SQLite on windows Phone 8

c# sqlite windows-phone-8

I have a Windows Phone application in wich I want to add NLog. The data from Nlog I want to put in a SQLite database.

How get Week day name in custom format using

c# string datetime weekday

Using following code get the current Day Name of a computer