Binary Decoding in Visual Studio/VB.NET

This is a discussion on Binary Decoding in Visual Studio/VB.NET within the Programming Languages forums in category; I have a 56 byte array of data. Document says that position 31-33 is a date value stored as a 3-byte (Binary Date - big-endian format). The values in these three bytes are 0,159, and 204. I have tried everything I can think of with the encoding methods in .net Here is my line of code that returns garbage data back...definitely not a date value RecDate = Encoding.BigEndianUnicode.GetString(e.Datagram.Buf fer, 31, 3) Any help is appreciated....

Go Back   Application Development Forum > Programming Languages

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-04-2008, 02:06 PM
sbenavides@dsgsolutions.net
Guest
 
Default Binary Decoding in Visual Studio/VB.NET

I have a 56 byte array of data. Document says that position 31-33 is
a date value stored as a 3-byte (Binary Date - big-endian format).
The values in these three bytes are 0,159, and 204.

I have tried everything I can think of with the encoding methods
in .net

Here is my line of code that returns garbage data back...definitely
not a date value

RecDate = Encoding.BigEndianUnicode.GetString(e.Datagram.Buf fer, 31,
3)

Any help is appreciated.
Reply With Quote
  #2  
Old 09-04-2008, 03:17 PM
Dan Mills
Guest
 
Default Re: Binary Decoding in Visual Studio/VB.NET

On Thu, 04 Sep 2008 11:06:51 -0700, sbenavides wrote:

> RecDate = Encoding.BigEndianUnicode.GetString(e.Datagram.Buf fer, 31, 3)
> Any help is appreciated.


What gives you the idea that it is a string?

I know SFA about your platform, but just reading the three bytes as a 24
bit big endian number gives me:

0 * 2^16 + 159 * 2^8 + 204 = 40908, which looks like september4th 08 to
me.
I would note the Y2 or 3K bug here.

Regards, Dan.


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 04:24 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.