hex

Want to form a string with given hex code values

I want to replace certain characters in an input string with other characters. The input text has Microsoft left and right smart quotes which I would like to convert to just a single ". I was planning on using the Replace operation, but am having trouble forming the text string to be searched for. I would like to replace the input seq...

Extract first two digits of hex (UInt32 *) and convert to int

I have a bunch of hex values stored as UInt32* 2009-08-25 17:09:25.597 Particle[1211:20b] 68000000 2009-08-25 17:09:25.598 Particle[1211:20b] A9000000 2009-08-25 17:09:25.598 Particle[1211:20b] 99000000 When I convert to int as is, they're insane values when they should be from 0-255, I think. I think I just need to extract the firs...

How do I Console.WriteLine as hexadecimal?

The Following code prints out '10'. How can it print out 'a'. int i=10; Console.WriteLine("{0}", i); ...

PCRE to replace #334455 hex with #345

I'm writing a function that replaces long hex coded color (#334455) with short one (#345). This can be only done when each color in hex is multiple of 17 (each hex pair consists of the same characters). e.g. #EEFFCC is replaced with #EFC, but #EDFFCC isn't replaced with anything. I want to make this with single preg_replace() call with...

After reading in bytes from file, most are right except 1 is wrong and negative

In Java, I just read a file into a ByteBuffer. When I started checking to make sure that the ByteBuffer contained the right bytes, I noticed that it had mostly the correct start and end bytes, except for the 3rd byte, it has -117 instead of what emacs says should be 139 (8b in hexl-mode). What gives? Does this have something to do with B...

Linearly increasing color darkness algorithm

Hi, I want to write a function in ruby that given a number between 1 and 500 will output a 6 digit hex color code that gets linearly darker for higher numbers. This doesn't seem that hard but I'm not sure where to begin. How can I implement this? edit Hue seems like a more reliable way to go. I'd like to give a reference color, say a...

C# convert hex into ip

i have hex values in the format of 4a0e94ca etc, and i need to convert them into IP's, how can i do this in C# ? ...

What is &H14& in VBScript?

I found the following article : here about installing fonts on a Windows computer via a script. The author uses VBScript to do that, but I'd like to use Ruby/Python. There is a line in the script I don't understand : Const FONTS = &H14& What is that &H14&? Is it a number? How would I represent that in another language? ...

What is the specification of Hexadecimal Date format in SQL server?

SQL Server Management studio generated value of datatype "Date" into following string: CAST(0x38320B00 AS Date). I need to convert it into classical .NET datetime (i have the string in c# app). I know that if it were SQL Server DateTime it would be 2 times longer Hex number and first part would specify number of days from 1.1.1900, an...

Java - writeLong method of DataOutputStream and writing hex

Currently, I have: outByte.writeInt(0x49492a00); outByte.writeInt(0x08000000); But i want to be able to write all of that on the same line. But: outByte.writeLong(0x49492a0008000000) is underlined red in Eclipse, and therefore incorrect. Is it possible to write those two lines all in one with writeLong()? ...

Problem with hex literal in string comparison

I'm reading in an NES ROM file, where the first four bytes are "\x4e\x45\x53\x1a", or NES\x1a. In my actual code, the given file can be arbitrary, so I want to check to make sure this header is here. However, I'm running into some trouble, which the following code demonstrates: #include <stdio.h> #include <string.h> int main() { FILE ...

Hex representaion of bytes in a String

I read somewhere that string 0123456789ABCDEFFEDCBA987654321089ABCDEF01234567 is 192 bit (24). Its written that it is a "hex representation of bytes" I need help on this concept. PS: This is secret key of TripleDES algorithm. ...

Converting hex string stored as chars to decimal in C

I'm given a string hex_txt containing a 4 digit hex number in the way outlined in the code, split up in two array entries. I need to convert it to decimal. The following is the way I'm doing it. unsigned char hex_txt[] = "\xAB\xCD"; unsigned char hex_num[5]; unsigned int dec_num; sprintf(hex_num, "%.2x%.2x", (int)hex_txt[0], (int)hex_t...

How to Parse Negative Long in Hex in Java

We have a J2ME application that needs to read hex numbers. The application is already too big for some phones so We try not to include any other codec or write our own function to do this. All the numbers are 64-bit signed integers in hex, when we use Long.ParseLong(hex, 16), it handles positive numbers correctly but it throws exception...

Method to convert from Hex to Integer in C, can't get lowercase!

Hey everyone, just a quick thing, I have the hex to integer working, but I need to get the numbers lowercase. Here's what I have, any ideas to get to get the A thru F case insensitive? int htoi(char f[]) { int z, n; n = 0; for (z = 0; f[z] >= '0' && f[z] <= 'F'; ++z) if (f[z] >= 'A' && f[z] <= 'F') n ...

Convert hex to decimal in make script?

A make script is attempting to set a variable as follows: VER_DEC=$( perl -e "print hex(\"$(VER_HEX)\");" ) where VER_HEX happens to have a value of 0a. Perl seems to think that VER_HEX is zero, implying that the variable isn't set (but it is, according to a debug echo in the makefile). Does make have a simpler way to convert bases?...

Convert hash to a hexadecimal character string

on this page: http://www.shutterfly.com/documentation/OflyCallSignature.sfly it says once you generate a hash you then: convert the hash to a hexadecimal character string is there code in csharp to do this? ...

3 digit Hex color code

I've been using 3-digit Hex color values in CSS for a long time: #fff, #999, #069 etc., I can see how the repeating alphabets/numbers are merged to create a 3-digit hex color code, but I don't fully understand the pattern to be able to write a converter in PHP. Is there a documentation for this? Edit: Oh, perhaps my question wasn't clea...

Encoding/decoding REST path parameters

I am trying to find the best way of getting round a design flaw in a web app I'm helping to support. One part of the service passes a parameter ("myparam") to a .jsp page, which in turn calls a REST service including our myparam as a path parameter. The design flaw bit is that myparam should be passed as a form parameter, since it can be...

hex string to signed short int in c++

Hi, I could find the code to convert a hexadecimal string into a signed int (using strtol), but I can't find something for short int (2 bytes). Here' my piece of code : while (!sCurrentFile.eof() ) { getline (sCurrentFile,currentString); sOutputFile<<strtol(currentString.c_str(),NULL,16)<<endl; } My idea is to read a file with 2 byt...