hex

Search Hex substring in string

Hi all! Well i got a socket that receives binary data and I got that data into an string, containing values and strings values too. (for example "0x04,h,o,m,e,....") How can i search for an hex substring into that string? I.e. i want to search "0x02,0x00,0x01,0x04". I'm asking for a c++ version of python 'fooString.find("\x02\x00\x01...

c why does this print a negative number?

I was expecting this to print a very large number and that same number -1 but it just prints -1 and -2, why is this? fprintf(stderr, "%d\n", 0xffffffff); fprintf(stderr, "%d\n", 0xfffffffe); ...

I don't understand how Assembly works with ASCII?

I have a program that's supposed to take values and print them back out. But when the user enters something like 12, (C in HEX) the program prints out some weird letter, that I think is the representation in ASCII. Is there a way to make it save those numbers as raw numbers? I'm doing the input and output through an external library, so ...

How can I convert hex strings into numbers in Perl?

I recently wrote a script which parsed a text representation of single binary byte month field. (Don't ask :-{ ) After fiddling with sprintf for a while I gave up and did this; our %months = qw / x01 1 x02 2 x03 3 x04 4 x05 5 x06 6 x07 7 x08 8 x09 9 x0a 10 ...

Hex to char array in C

Given a string of hex values i.e. e.g. "0011223344" so that's 0x00, 0x11 etc. How do I add these values to a char array? Equivalent to say: char array[4] = { 0x00, 0x11 ... }; ...

iPhone: change hex color format to UIColor

hi all, i am creating a application, in which i pick the color of label from XML file.XML file return the color in Hex format(for ex. #00FF00). so how can i change this value to UIColor ...

Read In Hex Values (C)

Hello all. I am currently attempting to read in Hex values from a text file. There can be multiple lines of Hex's and each line can be as long as needed: f53d6d0568c7c7ce 1307a7a1c84058 b41af04b24f3eb83ce Currently, I put together a simple loop to read in the Hex values into an unsigned char line[500] with fscanf as such: ...

Python convert hex to float

How to convert the following hex string to float (single precision 32-bit) in python? "41973333" -> 1.88999996185302734375E1 "41995C29" -> 1.91700000762939453125E1 "470FC614" -> 3.6806078125E4 Thanks ...

c++ hex number format

Hi,I'm trying to output the hex value of a char and format it in a nice way. Required: 0x01 : value 0x1 All I can get is: 00x1 : value 0x1 // or 0x1 if i don't use iomanip Here's the code i have, 'ch' was declared to be a unsigned char. Is there any other way to do it other than checking the value and manually add a...

Creating a ISO-8859-1 string from a HEX-string in Java, shifting bits.

Hello experts! I am trying to convert a HEX-sequence to a String encoded in either, ISO-8859-1, UTF-8 or UTF-16BE. That is, I have a String looking like: "0422043504410442" this represents the characters: "Test" in UTF-16BE. The code I used to convert between the two formats was: private static String hex2String(String hex, String enc...

Why is this statement true in PHP?

I don't understand why this statement in PHP echos 'whaaa?' -- (0x0F | 0xF0) should be 0xFF no? if((0x0FFFFFFF | 0xF0FFFFFF) != 0xFFFFFFFF) echo 'whaaa?'; ...

Detect non-printable characters in JavaScript

Is it possible to detect binary data in JavaScript? I'd like to be able to detect binary data and convert it to hex for easier readability/debugging. After more investigation I've realized that detecting binary data is not the right question, because binary data can contain regular characters, and non-printable characters. Outis's q...

What exactly is the danger of using magic debug values (such as 0xDEADBEEF) as literals?

It goes without saying that using hard-coded, hex literal pointers is a disaster: int *i = 0xDEADBEEF; // god knows if that location is available However, what exactly is the danger in using hex literals as variable values? int i = 0xDEADBEEF; // what can go wrong? If these values are indeed "dangerous" due to their use in various ...

convert decimal to hex python

Hi All, Im building a server in python, i need to convert a decimal value to hex like this : let's say the packet start by 4 bytes which define the packet lenght : 00 00 00 00 if the len(packet) = 255 we would send : 00 00 00 ff Now my problem is that sometimes the packet is bigger than 256 as for example 336, then it would be : 00 00...

Storing hexadecimal values as binary in MySQL

I was thinking about how I'm storing passwords in my database : appropriately salted SHA1 strings in a CHAR(40) field. However, since the character data in there is actually just a hex representation of a 160 bit number, I thought it might be better to store it as BINARY(20). CREATE TABLE users ( password BINARY(20) /* snip */ )...

decodeHexString obj-c implementation, Should I support odd lengthed hexstrings, and if so, how?

I may be missing something in the standard libs, but I don't think so. I have this current implementation: int char2hex(unsigned char c) { switch (c) { case '0' ... '9': return c - '0'; case 'a' ... 'f': return c - 'a' + 10; case 'A' ... 'F': return c - 'A' + 10; default: WARNING(@"pa...

How to interpret hexadecimal numbers like 0x0A?

What does 0x0A mean in C++ and how should I interpret or read such hexadecimal values? if (version < 760 || version > 760){ disconnectClient(0x0A, STRING_CLIENT_VERSION); } uint32_t accnumber = msg.GetU32(); std::string password = msg.GetString(); if(!accnumber){ disconnectClient(0x0A, "You must enter your account number."); ...

Hex 0x0001 vs 0x00000001

hi, often in code that uses permissions checking, i see some folks use hex 0x0001 and others use 0x00000001. these both look like an equivalent of a decimal 1, if i'm not mistaking. why use one over the other, just a matter of preference? ...

Read version info from .ABR file (Photoshop brush set)

Is it possible to detect which Photoshop version a brush set (.abr) file is compatible with from its binary data? There is a open source C# programm called ABRViewer but it doesn't read version info. Sample brushes: http://mark-s.deviantart.com/art/Fractal-Brushes-Set-20484978 http://redheadstock.deviantart.com/art/Arcane-Circles-Sym...

how to show hex code char ?

hi, i have a file contains numbers like FB8E,FB8F,FB90 on each line. i want in my program to load this file and take each line and print the character corresponded to that number/line. for expamle, my firnst line is FB8E, i want something to convert it like #$FB8E (arabic Kaf), how do i do that? ...