hex

Python: Hex data from socket, process and response

Hi all! Lets put it in parts. I got a socket receiving data OK and i got it in the \x31\x31\x31 format. I know that i can get the same number, ripping the \x with something like for i in data: print hex(ord(i)) so i got 31 in each case. But if I want to add 1 to the data (so it shall be "32 32 32")to send it as response, how can ...

MySQL 5.0: Output BLOB data in (well-formed) XML format?

I'm writing a web interface to MySQL that executes a couple queries and returns some XML data with the results of the queries. Right now, the table the query is running on has three LONGBLOB columns (for storing image data and the like). However, when I try to parse the XML, I run into trouble with certain characters in the BLOB columns...

Meaning of hex number in Windows crash dialog

Every now and then (ahem...) my code crashes on some system; quite often, my users send screenshots of Windows crash dialogs. For instance, I recently received this: Unhandled win32 exception @ 0x3a009598 in launcher2g.exe: 0xC00000005: Access violation writing location 0x00000000. It's clear to me (due to the 0xc0000005 code as well...

Algorithm to create hex flood puzzle

I'm creating a puzzle game that, while playable by hand for easy levels, is meant to be solved by computer programs for harder ones. The puzzle is a flood fill on a hexagonal board. You can try a prototype here. Here is how the puzzle works: by choosing a color from the top, you perform a flood fill starting from the upper-left tile. ...

C# convert integer to hex and back again

How can I convert the following? 2934 (integer) to B76 (hex) Let me explain what I am trying to do. I have User IDs in my database that are stored as integers. Rather than having users reference their IDs I want to let them use the hex value. The main reason is because it's shorter. So not only do I need to go from integer to hex b...

How do I get Netbeans to default to Hex display for watch variables?

In Netbeans 6.5 I am debugging a network stream and need to view the memory in Hex. The only way I have found to do this is to right click on each row and select display as Hex. This is very inefficient and I would like either a memory dump or default to hex. Is there a way to do this? ...

Are there any good reasons for using hex over decimal for RGB colour values in CSS?

rgb(255,255,255) notation has been available since CSS1. But #fffff seems to be vastly more popular. Obviously it's slightly more compact. I know that hex is more closely related to the underlying bytes, and understand that there would be advantages in carrying out arithmetic on those values, but this isn't something you're going to do ...

In emacs, how to strip CR (^M) and leave LF (^J) characters?

I am trying to use hexl mode to manually remove some special chars from a text file and don't see how to delete anything in hexl mode. What I really want is to remove carriage return and keep linefeed characters. Is Hexl mode the right way to do this? ...

Hex to Ascii? Java

Hi. I'm looking for a way to convert hex to ascii in Java. An example: byte temps[] = new byte[4]; temps[0] = 0x74; temps[1] = 0x65; temps[2] = 0x73; temps[3] = 0x74; String foo = ..(temps); System.out.print(foo); That should ou...

Convert a single hex character to its byte value in C#

This will convert 1 hex character to its integer value, but needs to construct a (sub) string. Convert.ToInt32(serializedString.Substring(0,1), 16); Does .NET have a built-in way to convert a single hex character to its byte (or int, doesn't matter) value that doesn't involve creating a new string? ...

Python: binary/hex string conversion?

I have a string that has both binary and string characters and I would like to convert it to binary first, then to hex. The string is as below: <81>^Q<81>"^Q^@^[)^G ^Q^A^S^A^V^@<83>^Cd<80><99>}^@N^@^@^A^@^@^@^@^@^@^@j How do I go about converting this string in Python so that the output in hex format is similar to this below? 242080...

subclassing int to attain a Hex representation

Basically I want to have access to all standard python int operators, eg __and__ and __xor__ etc, specifically whenever the result is finally printed I want it represented in Hex format. (Kind of like putting my calculator into Hex mode) class Hex(int): def __repr__(self): return "0x%x"%self __str__=__repr__ # this certainly he...

Large hex values with PHP hexdec

I have some large HEX values that I want to display as regular numbers, I was using hexdec() to convert to float, and I found a function on php.net to convert that to decimal, but it seems to hit a ceiling, eg: $h = 'D5CE3E462533364B'; $f = hexdec($h); echo $f .' = '. exp_to_dec($f); Output: 1.5406319846274E+19 = 154063198462...

Algorithm to map Numbers to Hex Colors

Hi all, Here's my situation. Say I have two columns of data containing different elements. I'd like to highlight with a different color, all matching elements between those two columns. Each of those elements has an ID, so I was thinking of creating a mapping function to tie an ID to a hex color. Any suggestions? This is what I...

How can I find islands in a randomly generated hexagonal map?

I'm programming a Risk like game in Codigniter and JQuery. I've come up with a way to create randomly generated maps by making a full layout of tiles then deleting random ones. However, this sometimes produces what I call islands. In risk, you can only attack one space over. So if one player happens to have an island all to them self, t...

Hex dump from memory location

Hi I use a pointer to specify some kind of "shared memory" which I use to exchange data between different processes/threads. Now I would like to have a hex dump of the content of the shared buffer. Does anyone know how to do that? thanks, R ...

CPP to Java conversion

Here's my scenario. I have an application written in C++ but not the complete source but the "meat" of it is there. I also have a compiled exe of this application. It communicates to a server somewhere here on our network. I am trying to replicate the C++ code in java, however it uses dwords and memory references, sizeof etc, all thi...

How can I create a Unicode character from its bytes when they are stored in different variables in Perl?

I am trying to Convert hex representations of Unicode characters to the characters they represent. The following example works fine: #!/usr/bin/perl use Encode qw( encode decode ); binmode(STDOUT, ':encoding(utf-8)'); my $encoded = encode('utf8', "\x{e382}\x{af}"); eval { $encoded = decode('utf8', $encoded, Encode::FB_CROAK); 1 } or p...

Java: File to Hex?

I have a file in Java FileInputStream in = null; try{ in = new FileInputStream("C:\\pic.bmp"); }catch{} I want to convert pic.bmp to an array of hex values so I can edit and save it as a modified version. Is there a java class to do this? ...

Hex Colour - Formula To Make It Brigter

Is there a formula I can use to make a hex colour value brighter? ...