Converting hex to int while reading a text file

Monika

I have few hex numbers that the last digit mean the length of the string after. for example
2E3F00004Sara
41590000AFavhilmnfr
Except from:
515900016Mickael Barrie Linwood
Which is 22 not 16..
any idea how to get it from the number? Thank you

Pablo Santa Cruz

First of all, 16 is right since 16 is hexadecimal representation for decimal 22:

16 in hex = 1*16 + 6 = 22

You could convert an hex string to an int number with this in C#:

int namelength = Convert.ToInt32("0016", 16);  
// namelength will be 22
namelength = Convert.ToInt32("000A", 16);  
// namelength will be 10

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

generate a hex file by converting strings into hex from a text file in Python

Automatic converting to integer while reading a file in pandas

Reading a text file and converting string to float

Reading from a text file, parsing it, then converting it to a csv

Reading a text file and converting them into polynomials

Converting HEX string into int

Printing hex and int together in a text file

reading a binary data and converting it to hex

Pandas Reading txt file as int instad of hex (str) (SOLVED)

Converting Text File into a List <int> (C#)

Reading two hex values from text file in c++

reading hex from text file and split it in c program

Converting hex string to hex int in python

C Free While Reading Text File

Junk characters while reading text file in java

VB skipping lines while reading in text file

Alignment of text while writing and reading a file

extracting column values while reading the text file

Converting char * to double while reading from binary file in C++?

Converting hex to negative int in Python

Converting file text to Hashtable and reading value using keys?

Reading a text file line by line and converting it into a list using only read()?

modify specific line of text while reading from a text file to list

Convert all the values of the text to int while reading in python

Reading a hex file C++

unsupported operand type(s) for <<: 'str' and 'int' while reading file

converting hex string to an integer while preserving the format

Python converting text data from dat file to int

Converting int digit into hex char - C programming