I have this string:
Hello world !! and I want to print it using Python as
hex() works only for integers.
How can it be done?
In Obj-C I used to convert an unsigned integer n to a hex string with
NSString *st = [NSString stringWithFormat:@"%2X", n];
I tried for a long time to translate this into Swift language, but unsuccessfully.
I'm having problem fixing the endianness of the value that I got.
What I'm thinking is separate a
WORD to two, convert them to hex, and store them in an array.
WORD is the "crc_data" that is return to my previous question(which has been answered).
I got a "result" data from the code of:
crc_data = 0A95
*Note: crc_data is datatype WORD
What I'm thinking is separate them into two, and make them as hex. Like this:
value_1 = 0x95value_2 = 0x0A
Is there a way to do that? I read something about "BITWISE" operation, but I'm not sure if that's the way to do it.
I want to take an integer (that will be <= 255), to a hex string representation
e.g.: I want to pass in
65 and get out
255 and get
I've tried doing this with the
), but that chokes on anything above
9 since it wants to take in a single character string.
I cannot believe there is no API to do this in GLib, for now I have only found people doing their own conversion, like here and here (function named "decode"). I would really like to find a way to do this in a simple GLib call, but if there is no way, the above methods don't work for me because the former is C++ (I'm using C/GObject) and the latter doesn't seem to work perfectly (I'm having problems with the length of the result).