473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

decoding hex string to readable text

4
Hi C# experts
I have a binary file when open with HexEditor, it shows like this

00000130h: 00 00 00 00 00 06 29 B9 07 D9 04 17 42 53 43 36;
00000140h: 39 30 30 20 4D 52 00 00 00 00 00 00 00 00 00 00;

I got the following output: )¹ÙBSC6900 MR

I have tried with several coding attempt but still not getting the expected output.
I can get the last few characters "BSC6900 MR" but the infront characters are weird

Expand|Select|Wrap|Line Numbers
  1. string hexString = "0629B907D9041742534336393030204D52";
  2.             byte[] tmp;
  3.             int j = 0;
  4.             tmp = new byte[(hexString.Length)/2];
  5.             for (int i = 0; i <= hexString.Length - 2; i += 2)
  6.             {
  7.                 tmp[j] =(byte)Convert.ToChar(Int32.Parse(hexString.Substring(i, 2), System.Globalization.NumberStyles.HexNumber));
  8.  
  9.                 j++;
  10.             }
  11.             return Encoding.GetEncoding(1252).GetString(tmp);
  12.  
I've been googling around still am stuck in the weird characters.
Please advise. Thanks in advance :)
Aug 27 '09 #1
2 8558
PRR
750 Expert 512MB
Look into Convert Between Hexadecimal Strings and Numeric types and maybe
Encoding.GetBytes method.
Aug 27 '09 #2
skkuan
4
Thanks. I figure this out after reading.
The hex string is a combination of characters, word and dword.
So I used Convert.ToUint32 to decode this.
Aug 28 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: steve | last post by:
Hi, I am opening a stream that is UTF encoded. I use fgetc to read the stream- which is binary safe. I add every character read to a string. But when I look at the stream, I see some...
40
by: Peter Row | last post by:
Hi all, Here is my problem: I have a SQL Server 2000 DB with various NVarChar, NText fields in its tables. For some stupid reason the data was inserted into these fields in UTF8 encoding. ...
0
by: Johann Blake | last post by:
In my need to decode a JPEG 2000 file, I discovered like many that there was no functionality for this in the .NET Framework. Instead of forking out a pile of cash to do this, I came up with the...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
3
by: Ron Clabo | last post by:
I have a URL Decoding issue. The text that needs to be decoded is: "123+H%F6gbergsgatan+st" The decoded version should equate to: "123 Högbergsgatan st"
5
by: Peter Jansson | last post by:
Hello group, The following code is an attempt to perform URL-decoding of URL-encoded string. Note that std::istringstream is used within the switch, within the loop. Three main issues have been...
14
by: BB | last post by:
Hello. i am trying to decode a block of (what i think is) base64 into text, and i have NO idea how to begin. I'm going to paste the whole string here, but i want to know the steps necessary to...
25
by: marcin.rzeznicki | last post by:
Hello everyone I've got a little problem with choosing the best decoding strategy for some nasty problem. I have to deal with very large files wich contain text encoded with various encodings....
6
by: Peter K | last post by:
Hi in the processing of some text files, I have found I have strings like: f=E5t pr=F8ve where the strings "=E5" and "=F8" are danish characters "å" and "ø". I can work this out myself,...
42
by: Santander | last post by:
how to decode HTML pages encoded like this: http://www.long2consulting.com/seeinaction2008/Simplicity_Beach_table/index.htm Is there script that will do this automatically and generate normal fully...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.