FAQ Database Discussion Community


Decode hex string to latin characters [duplicate]

php,hex,decode
This question already has an answer here: How to convert HTML entities like – to their character equivalents? 4 answers I have string: tomas there is decoded string tomas I found that there is hec decode type : http://www.codetable.net/unicodecharacters Does in PHP exists fuction to encode hex to latin...

mt_rand() gives me always the same number

php,random,numbers,hex
I have a problem with this function always my mt_rand() give me the same number: $hex = 'f12a218a7dd76fb5924f5deb1ef75a889eba4724e55e6568cf30be634706bd4c'; // i edit this string for each request $hex = hexdec($hex); mt_srand($hex); $hex = sprintf("%04d", mt_rand('0','9999')); $hex is always changed, but the result is always the same 4488. Edit $hex = str_split($hex);...

C++ char* to HEX conversion

c++,hex,type-conversion
I want to convert byte data (file body) to hex in order to print it. I've copied a function for conversion, but not exactly understand it. #include "stdafx.h" #include <iostream> #include <Windows.h> #include <string> std::string byte_2_str(char* bytes, int size) { char const hex[16] = { '0', '1', '2', '3', '4',...

Xcode - Colours look different but should be the same

ios,xcode,hex,uicolor
In my app, I am using the following color: #3D6D86 It is set to be a background color on a view controller and also to be the color for the navigation bar on a different view controller. However the problem is that the color appears different. I converted the hex...

HTML hex to polish characters

c#,html,hex
I'm downloading HTML file with polish characters, and parsing it to string by: public static string HexToString(string hex) { var sb = new StringBuilder(); for (int i = 0; i < hex.Length; i += 2) { string hexdec = hex.Substring(i, 2); int number = int.Parse(hexdec, NumberStyles.HexNumber); char charToAdd = (char)number;...

python sending a hex string to serial port

python,serial-port,hex
I am trying to send a hexadecimal string to a serial port  and it has to be in the following format '\x02\x81....'  this is my code from binascii import unhexlify string='0281E1B1' print unhexlify(string) gives me  some randon symbols ?a+ instead of \x02\x81\xE1\xB1 I have python 2.7 so decode('hex') isnt working...

Regex for any matches from a list of words not preceded by @

regex,hex,sublimetext2,keyword,keyword-argument
I inherited a front-end web project with a few dozen grossly disorganized Less pages. I need to track down stray colors and unify with a brand standard. My understanding of regex is fairly limited, but if I understand correctly, one or more might make my life a lot easier. I'm...

Hex change low to high and then conever to decimal

c#,order,hex,decimal
I have Hex string like 1480D604. Which I need to change order from Low to High 0x04D68014 and then I need to cast it into decimal value. One approach that I can think is first change their order first like. Step 1 : 14-80-D6-04 --> 04-D6-80-14 How can I change...

PHP Replace binary file at hex address [closed]

php,replace,binary,hex,preg-replace
I want to modify a binary file server side of aprox. 700kb to change an url in it than save it. My first idea was to use bin to hex and preg_replace to replace url in binary. The adress for the url in binary is always the same, but i...

scanf a big hexadecimal value

c,hex,scanf
I have a issue trying to use scanf to get a big hexadecimal num (12 chars) from the user. it seems to only get the last 8 chars, eg - ABFFFFFFFF will become 0000FFFFFFFF. this is my code - unsigned long long address; scanf("%x",&address); printf("Address: %#014x", address); for this input:...

Generate string from 00:00:00 to FF:FF.FF in php

php,hex,counting
I need to generate and echo values from 00:00:00 to FF:FF.FF like for counting from 1 to 1000000. I know with numbers but how with hexadecimal numbers? for example I need this at echo: 00:00:00 00:00:01 00:00:02 . . . FF:FF:00 FF:FF:01 FF:FF:02 . . . FF:FF:FF How to do...

How to Convert Binary to Hex

binary,hex,byte,bits
So I have a binary number but there's only 11 bits. The number: 10111101110 I need to convert this to hexadecimal. I divide into three parts: 101 1110 1110 I know the last two parts are EE The part with three bits is catching me. If i add a zero...

How to convert binary to hex code digit-wise

c++,binary,hex
In C++ I've four binary numbers stored in four strings, let's say: string s1="1010", s2="1011", s3="0100", s4="0011"; OR directly stored as ints: int i1=10, i2=11, i3=4, i4=3;. I don't know which situation will lead to the better solution, that's why I wanted to clarify, that I can start with both....

Convert larger value hex string into bytes using java

java,hex,hexdump,javax.comm
I am trying to convert a larger value of hex string into bytes. The information which is get about converting signed bytes is the max is 0x7F equals to 127 only. But now mine I want to convert hexa value C6 into bytes which i should receive 198. Are there...

Twig : Unescape hexadecimal text

php,html,symfony2,hex,twig
I try to secure email address on my website and I used the function (twig filter) below to encode it : /** * The twig filter associated with this function is "encode_email" */ function encode_emailFilter($email) { $text = $email; $text_encode = ''; for ($x=0; $x < strlen($text); $x++) { $text_encode...

Benefits of storing hex in DB over file

php,mysql,sql-server,binary,hex
I've been tasked with migrating an in-house application from ASP with a MSSQL backend to PHP with MySQL. The application allows users to upload and download files, searching the content therein etc... After scoping out the current application, I've discovered that the previous developer stored the hex values of the...

Print unsigned char array to hex [duplicate]

c++,hex,unsigned-char
This question already has an answer here: How to print unsigned char[] as HEX in C++? 1 answer The problem I've got some byte buffer, that get's filled during runtime. I want to display the buffer's content, using hex-code. So this is the definition of the buffer: enum {...

Python 2.7: dictionary (switch statement) values

python-2.7,dictionary,hex
Python 2.7: dictionary (switch statement) values I'm decoding (a string array of) hex values to a floats and I'd like to use a dictionary to store the resultant float values though I can't see how to. For a quick fix I've used a if-elif statement to do this - is...

Storing data in a hexagonal grid for word search Python

python,python-3.x,grid,hex
newbie to Python. I would like to know how to store letters in a hexagonal grid. I tried using graph but I do not understand it too well. The first letter (from a file or something) goes to the center hexagonal box of the honeycomb structure, and the next set...

c# convert a string hex to ascii ? string reading from a csv file

c#,string,hex
I'm trying in C# and visual studio express to convert a very long string of chars that contains hex data names in ASCII words Example : The file column that I read contain the string 4E 4F 54 49 46 59 .................. (continue) that means in ASCI "NOTIFY" My program...

Hex form for a sha1 hash of a String?

string,haskell,hash,hex,sha
I need a sha1 hash of a string in HEX form. This is the basic code: import Data.ByteString.UTF8 import Crypto.Hash.SHA1 (hash) toArgs :: String -> (String,String) toArgs str = let h = show . hash . fromString $ str in (str,h) Which produces the hash, but in a form like...

Add hexadecimal from file to List

c#,arrays,hex,byte
I'm trying to make a List<byte> from a file that contains string (Hexadecimal) . the definition is : List<byte> myArray = new List<byte>(); if I want to add my information directly I use something like this : myArray.Add(0xb8); Note : Without any quotation or double-quotation . The problem is when...

What is the internal structure of a Windows shortcut?

windows,hex,structure,shortcut
3 HDD in one computer: 2 with Windows XP, 1 with Windows 7, sequentially load the operating system from each of them. I discover that some working shortcuts (not all) which created in first XP don't work in second XP and Windows 7 (not available for viewing the object for...

Converting character to hex in assembler

assembly,hex,character,base,data-conversion
So right now I'm working on reading in a single character from the keyboard and displaying its hex value. At the moment I believe I'm getting the correct hex value, but it is not being displayed correctly. For example, 'k' is 6F in hex, but it's displaying as '6;'. I...

How to convert from Int64 to hex and from hex to byte in c#

c#,hex,type-conversion,byte,int64
I am trying to send a byte array to micro controller over serial port. This is an example array which can successfully communicate with micro controller: byte[] getCommandArray = new byte[7] { 0x02, 0x0D, 0x01, 0x03, 0x30, 0x44, 0x03 }; What I need to do is read different values from...

How to escape from hex to decimal

c,escaping,hex
I apologise if this is an obvious question. I've been searching online for an answer to this and cannot find one. This isn't relevant to my code per se, it's a curiosity on my part. I am looking at testing my function to read start and end bytes of a...

How to convert a hex address from a char buffer to be written to memory

c,string,assembly,hex,buffer
So i got this function here, which is called from the main function: void overflow(char *arg) { char buf[1369]; strcpy (buf, arg); printf ("Thank you for contacting customer service. You are so important to us that we wrote a program to serve you.\n"); printf ("Please hold for %u minutes while...

Sorting and displaying a TreeMap by Increasing value Issues

java,sorting,iterator,hex,treemap
I am working on a TreeMap with an iterator that reads a text file with 20 name and hexadecimal values for example RED; FF0000. First in the main I made an Iterator but I am not sure why its not reading all 20 and displaying. Also trying to sort them...

Convert a 0-1 value to a hex colour?

javascript,colors,hex,rgb,rgba
I'm creating an app that visualises stars using a NASA API. The colour of a star comes back as a 0 to 1 value, with 0 being pure blue, and 1 being pure red. Essentially I need to set up a way to convert 0-1 values in javascript to a...

c# manipulating a string as a hex code?

c#,hex
If I want to work with string to represent hexadecimal values, is there a way to make bitwise AND, bitwise OR and such between them? I know there are types which can handle that, but I'd need to keep them as string....

Python: Check whether the list is in sequential or not | End of the list is defined

python,list,hex,sequence,enumerate
My function is something like this, thanks to this answer, which is to check whether all the values of mylist are sequential or not, which is hexadecimal list. For example: mylist1 = ['03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c','0d', '0e', '0f'] mylist2 = ['03', '05', '06', '07',...

How to count the number of characters in a line in a csv file

java,csv,hex,converter
I have a Justice_League.csv file that has four lines with commas between them. I want to count the number of characters there are in each line and convert that number to hex. Below is the contents of Justice_League.csv: Bruce Wayne,Batman,None,Gotham City,Robin,The Joker 43 2B Oliver Queen,Green Arrow,None,Star City,Speedy,Deathstroke 50 32...

why the hex address is 14 character?

c++,variables,hex
in the hex address like: 0x7fffd7c24334 why number of digits is 14? is it 14 character for every hex address? I try it for some variable like double and int but it was just 14 character. is it obey some rules? thanks for all answers.

Converting an Array of Hexadecimal Strings to Numbers

javascript,hex,typed-arrays
I have an application in which a server is sending a lot of data every second to clients that request it. In this data set are several (large) arrays that contain numbers (in some cases 16-bit integers and in others double precision floats). In order to reduce the packet size,...

Converting a character array to be handled as a hex in C

c,arrays,hex,driver,uint32-t
I've just recently been required to work with C—I normally work with Python and a bit of Java—and I've been running into some issues. I created a function that converts a base-10 unsigned int into a character array that represents the equivalent hex. Now I need to be able to...

0x00 hex over TCP socket in QT

qt,tcp,hex,bytearray
I have problem with sending 0x00 over tcp. Data like 0x01 are ok, server receiving as 00000001, but when is 0x00 - no receive message on serwer. Client code: QByteArray sender="\x00"; socket.write(sender); Server code: QByteArray Data = socket->readAll(); QString str = QString(Data.toHex()); qDebug()<<str; //disp bytes char myByte = Data.at(0); for...

Convert binary string to hex string and keep its leading zeros

python,string,binary,hex
May I know how to write a Python script to convert binary string to hexadecimal string and keep the leading zeros? For an example, I have binary string "0000000000001010" and would like to print it into "000A". I know i can use zfill() function, but the number of leading zeros...

Multi-Color Gradient Fade for Text without CSS?

php,colors,hex,rgb,linear-gradients
I'd like help getting this PHP function to work with a third color option. Note: No CSS. No Javascript. Just PHP and HTML. <?php function Gradient($HexFrom, $HexTo, $ColorSteps) { $FromRGB['r'] = hexdec(substr($HexFrom, 0, 2)); $FromRGB['g'] = hexdec(substr($HexFrom, 2, 2)); $FromRGB['b'] = hexdec(substr($HexFrom, 4, 2)); $ToRGB['r'] = hexdec(substr($HexTo, 0, 2)); $ToRGB['g']...

Python: split bytes with a hexadecimal delimiter

python,split,hex
I'm working with a couple of binary files and I want to parse UTF-8 strings that exist. I currently have a function that takes the starting location of a file, then returns the string found: def str_extract(file, start, size, delimiter = None, index = None): file.seek(start) if (delimiter != None...

Parse the hexadecimal string to XDocument

c#,xml,visual-studio,hex
My code string workflowIdRef="WorkflowUser_NEW B&#xEC;nh Thu&#x1EAD;n Copy" string requestFileXml = HttpContext.Current.Server.MapPath("~/Admin/TS/requestXml/JobCreateReq.xml"); XmlDocument xmld = new XmlDocument(); xmld.Load(requestFileXml); string requestXml = xmld.OuterXml; requestXml = requestXml.Replace("WORKFLOW_ID", workflowIdRef); //Parse string requestXml to xDocument Temp XDocument xTemp = XDocument.Parse(requestXml); I debug and see below result Text Visualizer mode: And XML visualizer: The XDocument XTemp...

PHP decode literal string

php,string,hex,bin
in php for decode a hex string we use hex2bin() function for example "test" in hex is : "74657374" Now i want to add \x format to them , Like this : \x74\x65\x73\x74 How do i can decode this ? I wrote a function that removes \x from this string...

PHP print hex values of characters in a string

php,arrays,string,hex,character
I want to print the hexadecimal values of each of the characters in a PHP string. For example, I want to display the hex values of each character in a string where I'm trying to set the fourth character to Control-C (0x03). $str=sprintf('ab1%c',0x03); for ($cnt=0; $cnt<4; $cnt++) { $chr=$str[$cnt]; echo...

objective c convert int to unsigned char hex

objective-c,char,int,hex
I've to convert int x = 4 in to unsigned char y = 0x04 int x = 0 in to unsigned char y = 0x00 int x = -4 in to unsigned char y = 0xFC int x = -8 in to unsigned char y = 0xF8 and so on,...

Splitting a 200 bit hexadecimal bitmask [closed]

c#,hex,bitmask
I have a bitmask of 200 bit stored as a hexadecimal value. In order to apply the & bit operator, I have to first convert the hex to an integer but 200 bit is too big for a uint64 so my question is : how do I split my bitmask...

Program to read bytes from file and convert to hex

java,io,hex
import java.io.*; public class foo { public static void main(String[] args) { try { DataInputStream input = new DataInputStream(new FileInputStream( "data.dat")); while (input.available() > 0) { String hex = Integer.toHexString(input.readByte()); //I think this is where the problem is System.out.print(hex + ' '); } } catch (IOException e) { } }...

Difference between hexadecimal values and normal types

c,hex
I am doing an assignment in c: Basically I have a struct where it has char and int types. The assignment says that I have to fill the struct fields with some predefined values. The thing is that those values are represented as hexadecimal values. Since I am a bit...

PHP find 28-character hex regex in string

php,regex,hex,preg-match
In a very long line, i need to find a regex that matches something like this: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 now, that string is always made of hexadecimal characters, so it can be something like this also: ab ba 1a...

hex to string chinese,chinese hex 2 byte ,english hex 1byte?

java,string,hex,ascii
this is stringToHexAsciiString. //将字符串转成ASCII十六进制的java方法 public static String stringToHexAsciiString(String value) { StringBuffer sbu = new StringBuffer(); char[] chars = value.toCharArray(); for (int i = 0; i < chars.length; i++) { sbu.append(Integer.toHexString(chars[i])); } return sbu.toString(); } this is asciiToString begin //将ASCII转成字符串的java方法 public static String asciiToString(String value) { StringBuffer sbu = new StringBuffer();...

Store hex value in string C++

c++,hex
For example : char str[] = {0x1B, 0x54, 0x32, 0xFE, 0x88, 0x10, 0x34, 0x6F, 0x54}; But this is C style. So how can i do same with std::string and without using C functions?...

How to work with hex() in python?

python,python-2.7,int,hex
I've problem with hex() in python 2.7 I want to convert '0777' to hex with user input. but it have problem with using integer with user input. In [1]: hex(0777) Out[1]: '0x1ff' In [2]: hex(777) Out[2]: '0x309' In [3]: z = raw_input('enter:') enter:0777 In [4]: z Out[4]: '0777' In [5]:...

Why do you divide the raw data by 16?

math,hex,imp,squirrel
http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf Read page 3, Operation – Measuring Temperature. The following code works to get the temp. I understand all of it except why they divide the number by 16. local raw = (data[1] << 8) | data[0]; local SignBit = raw & 0x8000; // test most significant bit if (SignBit)...

Explanation of HEX value representation and Endianess

c,hex,endianness
I was working on a script to basically output some sample data as a binary blob. I'm a new intern in the software field and vaguely remember the idea of endianness. I realize that the most significant bits for big-endian starts at the top and works down the memory block....

Interpreting hex dump of java class file

java,class,hex
I understand the structure of a java .class file, but when I want to interpret the raw hex data I get a bit lost. This is a hex dump of a class file, excluding the header and constant pool. I understand the header to be the magic number, minor_version and...

Incorrect hex representations of characters with char but correct with unsigned char

c,file,hex
I was writing a function that prints the "hexdump" of a given file. The function is as stated below: bool printhexdump (FILE *fp) { long unsigned int filesize = 0; char c; if (fp == NULL) { return false; } while (! feof (fp)) { c = fgetc (fp); if...

How get int from hex with Objective-C?

objective-c,encoding,char,int,hex
I have char with hex value '\xa1', it's 161, and how I can get 161 in int value? This doesn't work for me: char a = '\xa1'; int b = a; And I have a uint8_t buffer[4], it reads bytes from NSInputStream, with hex value like this, how I can...

Java integer to hex and to int

java,integer,hex,data-type-conversion
I have the problem, that the method does not work as expected. In most cases it works. However there is a case it does not work. I have a byte array containing some values. In hex e.g.: 0x04 0x42 (littleEndian). If I use the method convertTwoBytesToInt, I get a really...

Converting decimal to hexadecimal byte in Java Card

hex,javacard,pkcs7,pkcs#5
I would like to convert a decimal (integer or short types) in Java to hexadecimal byte in a Java Card environment (only supports byte and short types and possibly int types). Example: int num = 254 Print out result: 0xFD My current method of using switches and if-else to handle...

Overflow with hexadecimal but not with variable

c,hex,overflow,bitwise-operators
I was joking around with bitwise operations, and I notice that: int y = 0x7fffffff; printf("%x",-~y); and prints 80000000 but if I do : printf("%x",-~0x7fffffff); it gives me an error of overflow: main.c:65:17: error: integer overflow in expression [-Werror=overflow] printf("%x",-~0x7fffffff); Does anyone know why -~y doesn't have the same behavior?...

How this code makes that hex values?

java,hex,notepad++,hex-editors
can any one explain me "in details" how this code makes a .cfg file that is like the picture in the left? I wanna change it so that it becomes like the right one? setLastFileInTNM(getTnmInstalledPath(), getLastPath()); private void setLastFileInTNM(String TNMConfigFilePath, String fileTobeSetInTNM) throws Exception { //fileTobeSetInTNM += " "; File...

Hardcode hexadecimal string values as color in ggplot

r,colors,ggplot2,hex
I have a data frame with "x" and "y" columns as numeric values, and a third column "cluster" as a hexidecimal string, an example seen below: library(ggplot2) library(scales) colList = c(scales::hue_pal()(3),"#520090") dat = data.frame(x=runif(100,0,1),y=runif(100,0,1),cluster=sample(1:4, 100, replace=T)) dat$cluster = factor(dat$cluster) levels(dat$cluster) = c(colList) head(dat) I am trying to create a scatterplot...

How to count the characters of each line in a string and convert the number to a hex

java,arrays,indexing,hex
I have this String here called message. Bruce Wayne,Batman,None,Gotham City,Robin,The Joker Oliver Queen,Green Arrow,None,Star City,Speedy,Deathstroke Clark Kent,Superman,Flight,Metropolis,None,Lex Luthor Bart Allen,The Flash,Speed,Central City,Kid Flash,Professor Zoom I need to count the number of characters in each line and print them in hex. First line should be (From Bruce to Joker) 2b Second...

Printing out the hex vale of an unsigned char array in C++

c++,string,hex,std,cout
I want to print out the hex value of an unsigned char array using the cout function. The most obvious approach would be something like the following. unsigned char str[] = "foo bar baz\n"; for(unsigned short int i = 0; i < sizeof(str); i++){ std::cout << std::hex << str[i] <<...

How can I convert from hexadecimal string to normal string?

java,android,hex,converter
I received to HTTP GET response as hexadecimal string data with socket in java. But I want to convert normal string to this data for HTML format. How can I make it ?

convert first column from hex to decimal using awk

linux,shell,awk,sed,hex
I have a log file which contains logs time stamp in Hexadecimal in column one and then log text in rest of the columns.For example: B60C0056: aaa1 bb1 ccc1 ddd1 eee1 fff B60C0056: aaa2 bb2 ccc2 ddd2 eee2 fff B60C0057: aaa3 bb3 ccc3 ddd3 eee3 fff B60C0058: aaa4 bb4 ccc4...

Split a string and convert individual pieces to hexadecimal

c,string,hex,strtol
I have a string like "03FE" holding hexadecimal values. I need to split this string in two parts, and convert each individual part to the equivalent hexadecimal. That is, I need 0x03 in one variable and 0xFE in another variable. For example, if I didn't have to split the string,...

Generating colors HEX in Excel

excel,colors,excel-formula,hex
I have data saved in Excel as numbers with calculated cumulative result (sum of all cumulative values is 100). *********************************** *Result*Cumulative* RGB * * 230 * 30 * HEX (darkest) * * 100 * 10 * HEX (lightest)* * ... * ... * ... * *********************************** I want to write...

Using Hexadecimal in Erlang

erlang,hex
Is there any way to convert a list of hexadecimal caracter to a binary that correspond to the hexadecimal coding Example: [FF,AC,01]=><<255,172,1>>

What are the values that appear at the address bar?

php,web,hex,type-conversion,translate
I am working on a webiste that translates an input string from Japanese to English. This webiste has two text fields and one button to submit the string for translation. But when I hit the button, I can see some kind of hexadecimal values separated by % in the address...

Save a hex-string to PostgreSQL column character varying

postgresql,hex
I want to save hex-string ('A2-5A-47-00-10-00-00-00') into a PostgeSQL database. My column is character varying(30). How can I do this?...

Found hex characters (\xHH) in access_log on Apache2

apache,logging,hex
In my RHEL 3 after installing Apache2 with CGI module is logging special hex chars in his logs/acces_log. Why Appear that? [18/May/2015:16:35:11 +0200] "\xac\xc4>\x90X\x7f\xdb\x18\x85\xf7\xcb\xd8FN\x1b\x1e\\\x89i\x13\xdf A\xae\x80\xa3\xee\xbaA\xa3\x1f\xc9orQi\xbd?\x1eD\x94\x87\xe7\x94HA\x83\xa0\x8b\xad\x14\x13tl|2M<\xdf\xf8\xe9\xb7\x04\xe5\xb0\x85\xd1\xf8\x07\xd9~\xca#-\t\x8e\xd3\x13!I\x82;\xe0\x97zX\x01\xc4\x03\xda\xcb10\x8b\x9b\xd0\xe1\xb2\xd6\xd7\x02\xfd\x01\xc5D\xc6\x06" 400 226 [18/May/2015:16:35:11 +0200] "POST...

How to generate hex sequence in Swift?

swift,hex
Hey guys I am trying to create a tool to calculate how many 6 bytes sequence it generates within a certain time set by me, like 10s or 1min and so on. The sequence, for example, is: 4F B0 33 47 A3 BC. So it's hex numbers and each 6...

Hex string compress

asp.net,vbscript,compression,hex
i have a code which encrypt and decrypt string with secret key <% Dim a, string, key string = "АБВГДЕЁЖЗИЙКЛМНОП РСТУФХЦЧШЩЪЫЬЭЮЯZàáâ{'-+/}äãåąčćęèéêëėįìíîïłńòóôöõøùúûüųūÿýżźñçčšžÀÁÂÄÃÅĄĆČĖĘÈÉÊËÌÍÎÏĮŁŃÒÓÔÖÕØÙÚÛÜŲŪŸÝŻŹÑßÇŒÆČŠŽ∂ð~!@#$%^" key = "CaIm^0=SGQWp1aL" a = s2h(string,key) response.write(a) response.write(h2s(a,key)) Function s2a(s) ReDim a(Len(s) - 1) Dim i For i = 0 To UBound(a) a(i) = Mid(s, i + 1, 1)...

Java Accessing Hexidecimal Text Files For HashMaping

java,iterator,hashmap,hex,bufferedreader
I am making a GUI were I have to make buttons and the background changes. The program is using a Java Collection Framework were I went with a Hashmap. I am really having trouble understanding and trying to do is access a txt file then read the pairs and store...

Assembly - Combining and storing characters from string with XOR

assembly,hex,masm,xor,cpu-registers
I'm working on a program which takes a person's name, loops through each character in the name, and combines each character using the XOR command. The program clears the AL register only, NOT the rest of the EAX register.The final XOR result is then stored in the AL register. Code:...

Javascript: Changing defined color value in a CSS file

javascript,hex
As you can see in the code snippet below, I've created a simple colored box in red using HTML and CSS. I want to create a Javascript file, that checks the current day of the month: If today is the 1st day of the month it should display the box...

Java String, single char to hex bytes

java,hex
I want to convert a string by single char to 5 hex bytes and a byte represent a hex number: like String s = "ABOL1"; to byte[] bytes = {41, 42, 4F, 4C, 01} I tried following code , but Byte.decode got error when string is too large, like "4F"...

C Kernel - Works fine on VM but not actual computer?

c,assembly,operating-system,kernel,hex
I am making a basic C kernel. (Loaded by an assembly program) I am compiling it with an i686-elf cross compiler for windows. My C code is as follows: void cls(); void drawhappy(); void main(){ char *vidptr = (char *)0xb8000; cls(); drawhappy(); } void cls(){ char *vidptr = (char *)0xb8000;...

Python: Check whether list is sequential or not

python,list,hex,iteration,sequence
Want a function / statement, to check whether all the values of mylist are sequential or not, which is hexadecimal list. For example: def checkmylist(mylist): #code returns True or False mylist1 = ['03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c','0d', '0e', '0f'] mylist2 = ['03', '05', '06', '07',...

Convert ASCII data to hex/binary/bytes in Python

python,sockets,hex
The protocol for a device I'm working with sends a UDP packet to a server (My Python program, using twisted for networking) in a comma separated ASCII format. In order to acknowledge that my application received the packet correctly, I have to take a couple of values from the header...

Base64 encode/decode issue

openssl,hex,base64,ocaml
I have two functions to convert to and from base64 using openssl: (* base64 encode *) let encode_base64 msg = let open_ssl_arg = "echo -n '" ^ msg ^ "' | openssl enc -base64" in let ic = Unix.open_process_in open_ssl_arg in let rec output s = try let new_line =...

What is the point of writing your code with hexadecimal notation for numbers?

c++,binary,hex
I was just reading a programming book the other day which talked about writing better code. I got to a section which described how to take any binary number and convert it to hexadecimal notation. I'm sort of new to programming and I was wondering what the advantage was of...

RDM880 RFID reading anomaly on Arduino

string,serial-port,arduino,hex,rfid
I've an RDM880 HW to read some 13.56MHz cards. I've read the protocol of comunication and writed a sketch following some guides i found on the net. I'm able print on serial the response from the reciver correctly, but when i try to store it to use it, i encountering...

Convert Binary File To String In Perl

perl,binary,hex,ascii
Ok. I have spent the last 14 hours trying to figure this out. I have a binary file with the following contents - (much more, but this is truncated version). I wish to convert this to readable string format. ^@^P<9A>^@^@^A^@[email protected]^@^@^A^@[email protected]^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^F<9A>^@^@^@^@^@^@[email protected]]U:^@^M^@...

Field packing to form a single byte

objective-c,c,hex,bitwise-operators
I'm struggling to learn how to pack four seperate values into a single byte. I'm trying to get a hex output of 0x91 and the binary representation is supposed to be 10010001 but instead I'm getting outputs of: 0x1010001 and 16842753 respectively. Or is there a better way to do...

How to embed hex values in a lua string literal (i.e. \x equivalent)

string,lua,escaping,hex,string-literals
In various languages, you can embed hex values in a string literal by using the \x escape sequence: "hello \x77\x6f\x72\x6c\x64" How can I do the same thing in Lua 5.1?...

Assembly Language - Converting Two's Complement Hexadecimal to its Base 10 Equivalent

assembly,hex,decimal,data-type-conversion,base
I am currently trying to figure out how to make the correct conversion from two's complement hexadecimal to its base 10 equivalent. We were given an assembly language program that adds and subtracts 32-bit integers and need to take the values of the registers and convert them. Here is what...

How to pack / unpack a hex string (high nibble first) with Elixir

hex,elixir
I was wondering how I would work with hex strings in Elixir. Specifically, I'm interested in converting from Hex to ASCII. In Ruby, an implementation of this may be: ["001C7F616A8B002128C1A33E8100"].pack('H*').gsub(/[^[:print:]]/, '.') How would I accomplish this task with Elixir? I have tried: <<00, 01, C7, F6...>> but this isn't a...

Escape string for javascript: hex in json

javascript,json,hex
This string {\x22Address\x22:\x22some address with quotes \\x22 \x22} is parsed by JSON.parse correctly in browser. Why? What do hex numbers mean in json string? I can't find explanation....

Python: Convert hex to string

python,string,hex
A value like 0x0F or 0x05 has to be given to a function as a string without the 0x at the beginning so 0F or 05. If I use str(hex(0x0F))[2:4] I only get f. It is crucial that the missing 0 is still present in my application. How can i...

Converting 8 digit hexadecimal number to decimal

numbers,hex,decimal,autoit,definition
I'm working on a AutoIt script and I have to convert some weird hexadecimal number to normal integer. But I don't know which procedure should I follow to convert my hex number. For example, in the AutoIt documentation below, some definitions and their hex values are given. But they didn't...

Assembly x86 “PSHUFB 128bit” implementation in another language

python,algorithm,assembly,x86,hex
I was reversing some application and i faced this opcode: PSHUFB XMM2, XMMWORD_ADDRESS and i tried implementing the algorithm of this function in python with no success! The reference of how this opcode should work is here: http://www.felixcloutier.com/x86/PSHUFB.html Here is a code snippet: PSHUFB (with 128 bit operands) for i...

Writing Byte Values in Bitmap Header To File

c++,bitmap,hex
I'm trying to write a bitmap header to file. For the moment, I just want to write the header without any pixel data. I'm basing the values on this, this, and this. I have the following function for composing a standard, uncompressed 24bit RGB bitmap header as a uint8_t: uint8_t*...

Put Hex Into .bin File

binary,hex
How would you stick a string of hexcode into a .bin file? Like this, \x45\x67\x89 for example. I've seen the long examples where you use bash to strip it then add it to the .bin, but there must be a quicker and simpler way? Also, I am not too familiar...

How to calculate CRC16 CCITT in PHP HEX?

php,hex,crc,crc16
I'm trying to use a PHP CRC16 CCITT function to calculate the checksum. A device sends me a PACKET with Checksum included: 10 00 00 00 00 00 00 00 12 51 09 08 00 18 00 04 02 14 00 0c 00 0c 02 1c 00 02 00 00...

Find and replace hex values in a String in Java using regex

java,regex,hex
In one of the sections in my website, users can enter a long piece of text. User may enter some machine dependent characters which are not rendered correctly, so I want to perform a validation check before they save their information. I have a range of hex values which are...

Convert Ascii value directly to Hex value

java,hex
I have a literal String made of the hexadecimal alphabet such as 00bff040dadd1fde55 and I wish to convert the string into its hex 'equivalent' in bytes i.e. into a byte array such as {0x00 0xBF 0xF0 0x40 0xDA 0xDD 0x1F 0xDE 0x55} Is there a Java class that can do...

Awk, little endian order and 4 hex digits

awk,hex,gawk,little-endian,dec
I suppose that I have a decimal number, e.g., 97254 ---> 00017BE6 (hex value) using: echo "" | awk '{printf("%08X", 97254)}' Now, if I want to convert hex number (00017BE6, in this case) into 4 numbers of 2 digits (max 8 numbers in input) in little endian order and CSV...

Parse a file of hex and split it up into 6-bit ints

c,arrays,hex
I've got a file containing hex code 01F640 01E120 04EF20 000000 and I want to add each 6 bits to an array. The array stores them as integers so the rest of the program can evaluate them. Here is the code I have so far. int main(int argc, const char...

All possible chars for representing a number as a String, Integer.java

java,integer,hex
In Integer.java, there is the following piece of code: /** * All possible chars for representing a number as a String */ final static char[] digits = { '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' ,...

java string Constant : hex value for a single character - how?

java,string,hex
I need to replicate a character in a unix file, that looks like this: cat myfile | xxd -ps | sed 's/[[:xdigit:]]\{2\}/\\x&/g' result -> ... \xa4 ... How can I put this character, which looks like hex A4 into a String literal in java? I tried this, but it doesn't...