Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

I am trying to make a C# AIS decoder. I am using this information a a base point http://www.bosunsmate.org/ais/[^]

I have managed to get the binary of each character, but I do not know how to convert it into its correct format now. For example, the MMSI binary is '010010110101011101110000101001'. I am getting this value, but how do I decode it and get the value '316005417' from it?
Posted
Comments
Richard MacCutchan 23-Nov-11 18:57pm    
Try explaining exactly what you are trying to do (post your code, don't expect everyone to follow the link), and what results you receive compared to those you expect, and people will try to help.

1 solution

Having a look at my answer to your last request Convert 8bit ASCII to 6bit[^]
and probably having a look at
convert.ToInt32()
and its 18 overloads might have lead you to
Convert.ToInt32(< your binary value >, 2)
 
Share this answer
 
v2
Comments
DominicZA 23-Nov-11 17:58pm    
No, it should decode into a string
Michel [mjbohn] 23-Nov-11 18:14pm    
then add .toString()
Michel [mjbohn] 23-Nov-11 18:21pm    
Why do you down vote my answer? Just because you don't like it?
DominicZA 23-Nov-11 18:32pm    
Um...because it doesnt make sense!! Binary can represent text! For example, '101101' could be decoded into 'e' Sayint Convert.ToInt32('101101').ToString() is going to do absolutely nothing!!!
Michel [mjbohn] 23-Nov-11 18:45pm    
You asked on how to decode e.g. (bin)'010010110101011101110000101001' into (int)316005417. And that's what Convert.ToInt32('010010110101011101110000101001',2) is doing.
And Convert.ToInt32('010010110101011101110000101001',2).toString() will return (string)'316005417'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900