Search Results

Search found 1516 results on 61 pages for 'hex editors'.

Page 13/61 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Why am I not getting the expected results with fread() in C?

    - by mauvehead
    Here is my code: #include <stdio.h> int main(void) { FILE *fp; unsigned int i; char bytes[512]; fp = fopen("myFile","r"); for(i = 0;i <= 512;i++) { fread(&bytes, sizeof(bytes), 1, fp); printf("bytes[%d]: %x\n", i, bytes[i]); } } Here is the expected output $ hexdump myFile 0000000 aa55 aa55 0060 0000 0a17 0000 b1a5 a2ea 0000010 0000 0000 614c 7563 616e 0000 0000 0000 0000020 0000 0000 0a68 0000 1001 421e 0000 0000 0000030 f6a0 487d ffff ffff 0040 0000 002f 0000 But here is what I see from my program bytes[0]: 55 bytes[1]: 8 bytes[2]: ffffffc8 bytes[3]: ffffffdd bytes[4]: 22 bytes[5]: ffffffc8 bytes[6]: ffffff91 bytes[7]: 63 bytes[8]: ffffff82 My obvious guess is that I'm either addressing something incorrectly and receiving the wrong data back or I am printing it incorrectly and viewing it the wrong way.

    Read the article

  • Is there a simpler way to convert a byte array to a 2-byte-size hexadecimal string?

    - by Tom Brito
    Is there a simpler way of implement this? Or a implemented method in JDK or other lib? /** * Convert a byte array to 2-byte-size hexadecimal String. */ public static String to2DigitsHex(byte[] bytes) { String hexData = ""; for (int i = 0; i < bytes.length; i++) { int intV = bytes[i] & 0xFF; // positive int String hexV = Integer.toHexString(intV); if (hexV.length() < 2) { hexV = "0" + hexV; } hexData += hexV; } return hexData; } public static void main(String[] args) { System.out.println(to2DigitsHex(new byte[] {8, 10, 12})); } the output is: "08 0A 0C" (without the spaces)

    Read the article

  • php XML DOM translates special chars to &#xYY;

    - by ZiTAL
    I send this with AJAX POST: <li><ul class "zone zCentral ui-sortable"><li><ul class="region rCol3 ui-sortable"><li class="" style=""><div><span class="tc tc_video">574081</span> <span>video: 'Mundo.Hoy': ¿Dónde habré olvidado... mi memoria?</span></div></li></ul></li></ul></li> I do this to create XML: header('Content-type: text/html; charset=utf-8'); if(isset($_POST) && isset($_POST['data'])) { $data = '<ul id="zone_container" class="ui-sortable">'; $data .= $_POST['data']; $data .= '</ul>'; $dom = new DOMDocument('1.0', 'utf-8'); $dom->loadXML($data); echo $dom->saveXML(); exit(); } and i get this: <?xml version="1.0"?> <ul id="zone_container" class="ui-sortable"> <li><ul class="zone zCentral ui-sortable"><li><ul class="region rCol3 ui-sortable"><li class="" style=""><div><span class="tc tc_video">574081</span> <span>video: 'Mundo.Hoy': &#xBF;D&#xF3;nde habr&#xE9; olvidado... mi memoria?</span></div> </li></ul></li></ul></li></ul> ¿Dónde habré olvidado... mi memoria? translates to: &#xBF;D&#xF3;nde habr&#xE9 ; olvidado... mi memoria? Y need original chars in the XML, these are utf-8 valid i don't know the reason for this encode :(

    Read the article

  • setBit java method using bit shifting and hexadecimal code - question

    - by somewhat_confused
    I am having trouble understanding what is happening in the two lines with the 0xFF7F and the one below it. There is a link here that explains it to some degree. http://www.herongyang.com/java/Bit-String-Set-Bit-to-Byte-Array.html I don't know if 0xFF7FposBit) & oldByte) & 0x00FF are supposed to be 3 values 'AND'ed together or how this is supposed to be read. If anyone can clarify what is happening here a little better, I would greatly appreciate it. private static void setBit(byte[] data, final int pos, final int val) { int posByte = pos/8; int posBit = pos%8; byte oldByte = data[posByte]; oldByte = (byte) (((0xFF7F>>posBit) & oldByte) & 0x00FF); byte newByte = (byte) ((val<<(8-(posBit+1))) | oldByte); data[posByte] = newByte; } passed into this method as parameters from a selectBits method was setBit(out,i,val); out = is byte[] out = new byte[numOfBytes]; (numOfBytes can be 7 in this situation) i = which is number [57], the original number from the PC1 int array holding the 56-integers. val = which is the bit taken from the byte array from the getBit() method.

    Read the article

  • What's the most effective way to interpolate between two colors? (pseudocode and bitwise ops expecte

    - by navand
    Making a Blackberry app, want a Gradient class. What's the most effective way (as in, speed and battery life) to interpolate two colors? Please be specific. // Java, of course int c1 = 0xFFAA0055 // color 1, ARGB int c2 = 0xFF00CCFF // color 2, ARGB float st = 0 // the current step in the interpolation, between 0 and 1 /* Help from here on. Should I separate each channel of each color, convert them to decimal and interpolate? Is there a simpler way? interpolatedChannel = red1+((red2-red1)*st) interpolatedChannel = interpolatedChannel.toString(16) ^ Is this the right thing to do? If speed and effectiveness is important in a mobile app, should I use bitwise operations? Help me! */

    Read the article

  • BigInteger.Parse() on hexadecimal number gives negative numbers.

    - by brickner
    I've started using .NET 4 System.Numerics.BigInteger Structure and I've encountered a problem. I'm trying to parse a string that contains a hexadecimal number with no sign (positive). I'm getting a negative number. For example, I do the following two asserts: Assert.IsTrue(System.Int64.Parse("8", NumberStyles.HexNumber, CultureInfo.InvariantCulture) > 0, "Int64"); Assert.IsTrue(System.Numerics.BigInteger.Parse("8", NumberStyles.HexNumber, CultureInfo.InvariantCulture) > 0, "BigInteger"); The first assert succeeds, the second assert fails. I actually get -8 instead of 8 in the BigInteger. The problem seems to be when I'm the hexadecimal starts with 1 bit and not 0 bit (a digit between 8 and F inclusive). If I add a leading 0, everything works perfectly. Is that a bad usage on my part? Is it a bug in BigInteger?

    Read the article

  • ActionScript 3.0 Color Output Error?

    - by TheDarkIn1978
    I'm employing color in a current AS3 project, and have come across what appears to be an error in the Flash Player (version 10). it might also be an error with Apple's DigitalColor Meter (version 3.7.2), which is what i'm using to sample the displayed colors on Mac OS X Snow Leopard (version 10.6.3). //Primary, secondary, and tertiary colors of the RGB color wheel var red:Number = 0xFF0000; var orange:Number = 0xFF7D00; var yellow:Number = 0xFFFF00; var chartreuse:Number = 0x7DFF00; var green:Number = 0x00FF00; var spring:Number = 0x00FF7D; var cyan:Number = 0x00FFFF; var azure:Number = 0x007DFF; //reads 0x0077FF var blue:Number = 0x0000FF; var violet:Number = 0x7D00FF; var magenta:Number = 0xFF00FF; //reads 0xFF00F8 var rose:Number = 0xFF007D; //reads 0xFF0077 all of these colors display normally except for 3: Azure, Magenta and Rose. they are coded with the appropriate number, but when i use the color meter to sample the displayed colors, those 3 return inaccurate results. anyone have any insight about this issue? what is causing the error, the Flash runtime or the color sampler? if it's the Flash player, could this problem be much deeper? *sampling this image will return inaccurate results due to .jpg compression. it's simply for illustration

    Read the article

  • Python: combine two neighbor list components

    - by kame
    When i use this code I get elements wich containing one number or letter. How to combine two neighbors? data = '4D41544C414220352E30204D41542D66696C652C20506C6174666F726D3A20504357494E2C2043726561746564206F6E3A20576564204D61792030352031363A31393A3337203230313020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020200001494D0F00000026000000789CE36360607000623620E680D220C00AE53343312310BA00692620E604F351010025BE00C8' data2 = list(data) print data2

    Read the article

  • Is there a simpliest way of doing this?

    - by Tom Brito
    Is there a simpler way of implement this? Or a implemented method in JDK or other lib? /** * Convert a byte array to 2-byte-size hexadecimal String. */ public static String to2DigitsHex(byte[] bytes) { String hexData = ""; for (int i = 0; i < bytes.length; i++) { int intV = bytes[i] & 0xFF; // positive int String hexV = Integer.toHexString(intV); if (hexV.length() < 2) { hexV = "0" + hexV; } hexData += hexV; } return hexData; } public static void main(String[] args) { System.out.println(to2DigitsHex(new byte[] {8, 10, 12})); } the output is: "08 0C 0A" (without the spaces)

    Read the article

  • String as \x03\x00\x00\x00 to integer

    - by marta
    Helo: I have a question, that I solved in c, but now I want to do it in hava: I have a String like: '\x03\x00\x00\x00' This is representing an hexadecimal value of a integer. I transform to 0x03\0x00... And now I want to obtain the integer, but I don't know how to do it in java could someone give me some idea ? Thanks in advance (Is it some way to use this format ('\x03\x00\x00\x00' ) directly without use byte[] arrays? and in C can I use this format directly to build a integer (int)?)

    Read the article

  • GWT Editor: How to set last modified time on the entity when saved?

    - by Mike
    Suppose at client side i have an Entity proxy to edit by the UI and when i click save button, the last modified time is save in the entity as a field. //start MyEntityProxy proxy = getProxy();//fetched from server Request<Void> saveRequest = requestFact.myEntityProxyRequest().save(proxy); editorDriver.edit(proxy, saveRequest.getRequestContext()); editorDriver.flush(); //user modifies UI .... //save editorDriver.flush(); saveRequest.fire(); The problem is, where to insert the proxy.setLastModifiedTime(data) call? I always got java.lang.IllegalStateException: The AutoBean has been frozen. Thanks.

    Read the article

  • What is this C function supposed to do based on description?

    - by user1261445
    unsigned int hex_c0c0c0c0(): Allowed operators: + - = & | ~ << ! >> Allowed constants: 1 2 4 8 16 Return 0xc0c0c0c0 The above is the description I have been given and I have to write the code for it. Can someone tell me what exactly the function is supposed to do? All the description says is what I have pasted above, so I'm not sure what my goal is. I'm sure it is an easy enough function to program on my own, but it would help if someone could tell me what the function is supposed to do, and maybe provide sample input/output so that I know my code is working correctly once I program this. Thanks.

    Read the article

  • char '0x8' what character is this?

    - by OHHAI
    I have a large amount of data in a database. When I attempt to read a certain portion of the data and generate some xml and send it to a webservice I get the following exception... The char '0x8' in 'java.lang.IllegalArgumentException'. I'm guessing it is some bad data, as it has worked perfectly for about 7 months but now some user uploaded some new data that seems to have some issues. Anyone know what character this is so I can just run a sql query and clean it from the db? Thanks in advance.

    Read the article

  • Programmatic gradient stops with Javascript

    - by TomcatExodus
    Working with Javascript (jQuery), given 2 color values (2033ff and 3300a0 for example) how can I determine certain gradient stops between them? Reason being is, I intend on using an array of color values: 0 => '000000' 8400 => 'f0ff00' 44000 => '2033ff' 68400 => '3300a0' There being 86400 seconds in a day, 12:00AM maps to 0, and 11:59PM maps to 86399. As time passes, the background color of a specified element changes to the appropriate color in gradient list via window.setInterval(function(e){ ... }, 1000). For example 2:32:11PM = 52331, which from the example would be somewhere between 2033ff and 3300a0. I don't need to populate the array with the values (unless that would be easier) but instead use the index and value as references.

    Read the article

  • How to divide hex grid evenly among n players?

    - by manabreak
    I'm making a simple hex-based game, and I want the map to be divided evenly among the players. The map is created randomly, and I want the players to have about equal amount of cells, with relatively small areas. For example, if there's four players and 80 cells in the map, each of the players would have about 20 cells (it doesn't have to be spot-on accurate). Also, each player should have no more than four adjacent cells. That is to say, when the map is generated, the biggest "chunks" cannot be more than four cells each. I know this is not always possible for two or three players (as this resembles the "coloring the map" problem), and I'm OK with doing other solutions for those (like creating maps that solve the problem instead). But, for four to eight players, how could I approach this problem? As always, any and all help is appreciated. :)

    Read the article

  • Do most web 'programmers' (not designers) use WYSIWYG editors or hand code their HTML?

    - by John MacIntyre
    When I started programming web pages, it became immediately obvious that the WYSIWYG editors sucked. The HTML output was difficult to maintain, did things in ways you may not have agreed with, completely messed up existing pages if opened, couldn't handle code in the page, and was polluted with dead or irrelevant code like <font ...></font>. At that time, I didn't know a single programmer with more than 6 months experience who didn't hand code their HTML. Even now, most of the developers I know hand code their HTML. But, I also realize this was a decade ago, WYSIWYG editors have improved, and I may be seriously underproductive hand coding my HTML. Do you, as a web programmer, use WYSIWYG editors for your HTML? PS-I'm kind of thinking we can just vote either YES or NO, and put comments below.

    Read the article

  • please help turn a simple Python2 code to PHP

    - by user296516
    Hi guys, Sorry to bother again, but I really need help transforming this Python2 code into PHP. net, cid, lac = 25002, 9164, 4000 import urllib a = '000E00000000000000000000000000001B0000000000000000000000030000' b = hex(cid)[2:].zfill(8) + hex(lac)[2:].zfill(8) c = hex(divmod(net,100)[1])[2:].zfill(8) + hex(divmod(net,100)[0])[2:].zfill(8) string = (a + b + c + 'FFFFFFFF00000000').decode('hex') data = urllib.urlopen('http://www.google.com/glm/mmap',string) r = data.read().encode('hex') print float(int(r[14:22],16))/1000000, float(int(r[22:30],16))/1000000 Would be great if someone could help, thanks in advance!

    Read the article

  • What feature is at play when Ctrl+Shift+Alt+U,E "types" an unprintable hex 000E?

    - by Peter.O
    I tend to use Ctrl+Shift+Alt for my customized system-wide keybindings. When I tried Ctrl+Shift+Alt+U it printed an underscored u and waited for more keyboard input!... Some keys were accepted and some were not... eg. Numbers were accepted and they too were underlined, but only a few keys allowed me to break out. I then tried Ctrl+Shift+Alt+U immediately followed by Ctrl+Shift+Alt+E. This produced an unprintable hex 000E(?) and broke out of the loop... The unprintable character got me thinking that this may be Unicode related. If so, how so? What is happening here? Is this underscored u a trigger for an Input Method Editor? This behaviour occurs: Here (as I type), "gedit", text-edit fields... (but not in the Terminal)... and "gvim" reported "pattern not found"...

    Read the article

  • Function that converts hex color values to an approximate color name?

    - by dclowd9901
    I don't suppose anyone knows of a function (PHP, preferably) that can take a hex color code and give an approximate color name for that hex value. I don't need a solution with 100s of colors. Even if it just amounted to the colors white, black, red, green blue, brown orange and yellow, I'd be pretty well in shape. If you don't know of an existing resource, does anyone know of a good way to approach this problem? Thanks in advance for the help.

    Read the article

  • C read X bytes from a file, padding if needed

    - by Hunter McMillen
    I am trying to read in an input file 64 bits at a time, then do some calculations on those 64 bits, the problem is I need to convert the ascii text to hexadecimal characters. I have searched around but none of the answers posted seem to work for my situation. Here is what I have: int main(int argc, int * argv) { char buffer[9]; FILE *f; unsigned long long test; if(f = fopen("input2.txt", "r")) { while( fread(buffer, 8, 1, f) != 0) //while not EOF read 8 bytes at a time { buffer[8] = '\0'; test = strtoull(buffer, NULL, 16); //interpret as hex printf("%llu\n", test); printf("%s\n", buffer); } fclose(f); } } For an input like this: "testing string to hex conversion" I get results like this: 0 testing 0 string t 0 o hex co 0 nversion Where I would expect: 74 65 73 74 69 6e 67 20 <- "testing" in hex testing 73 74 72 69 6e 67 20 74 <- "string t" in hex string t 6f 20 68 65 78 20 63 6f <- "o hex co" in hex o hex co 6e 76 65 72 73 69 6f 6e <- "nversion" in hex nversion Can anyone see where I misstepped?

    Read the article

  • jQuery jPicker colorpicker: How to convert from 8 digit (w Transparency) to standard 6 digit hex?

    - by Scott B
    I've got a jPicker installed and running fine; its a pretty sweet script. However, the value it returns to my input box is 8 digit hex. I need it to return 6 digit hex. Rather than post-process the 8 digit into 6, I'd rather just hack into the script and force 6 digit. Alternately, I'd be ok with hooking into the change event of the jPicker to intercept the value its sending to the input element and doing the conversion there just before it updates the input with the hex. Here's my code: $(function() { $('#myThemeColor').jPicker(); /* Bind jPicker to myThemeColor input */ $("#carousel").jCarouselLite({ btnNext: ".next", btnPrev: ".prev", visible: 6, speed: 700 }); And here's the code I'm working with to intercept the myThemeColor input's change event, but its not firing at all. $('#myThemeColor').change(function() { alert(this.val()); /* does not fire on any action */) if($(this).val().length == 8) { $(this).val(function(i, v) { return v.substring(0, 6); }); } });

    Read the article

  • Convert a string representation of a hex dump to a byte array using Java?

    - by ravigad
    I am looking for a way to convert a long string (from a dump), that represents hex values into a byte array. I couldn't have phrased it better than the person that posted the same question here: http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21062554.html But to keep it original, I'll phrase it my own way: suppose I have a string "00A0BF" that I would like interpreted as the byte[] {0x00,0xA0,0xBf} what should I do? I am a Java novice and ended up using BigInteger and watching out for leading hex zeros. But I think it is ugly and I am sure I am missing something simple...

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >