Multimobile Development: Building Applications for any Smartphone
System.BitConverter on Big-Endian-Platforms
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.compactframework.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Stefan Mecke
Hi all!

Could anyone please verify and post the behavior with MS.NET compact
framework on a big-endian system? The docs I found are not precise about
whether BitConverter always returns the platforms native endianness or
always little-endian like x86.

Thanks
Stefan Mecke

--------------------------------------------------------
using System;

public class Test
{
public static void Main(string[] args)
{
if (!BitConverter.IsLittleEndian){
byte[] ba;
int i4 = 45555;

ba = BitConverter.GetBytes(i4);

for (int i=0; i<ba.Length; i++)
{
Console.Write(" {0:x}", ba[i]);
}
Console.WriteLine();
} else {
Console.WriteLine("Little-endian-platform -- doesn't help");
}
}
}
Reply to this message...
Vote that this is a GOOD answer...
 
Really good experience at the Apple Store
MonoDroid – looking *awesome*
 
    
Chris Tacke, eMVP (VIP)
CE only runs on little-endian devices.....

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net

"Stefan Mecke" <Click here to reveal e-mail address> wrote in message
news:c2su38$20q0l1$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Steven
If you have need to read data produced by a big-endian system (such as a Palm database file), you might do as I did under the same circumstances. I read the data into bytes arrays one field/value at a time and manually reversed the bytes in the array. I then passed the reversed bytes into bitconverter. I have had no trouble reading Palm databases this way for quite a while.
Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Chris Tacke, eMVP (VIP)
Ah! Can't see the forest for the trees, sorry.

--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
Windows CE Product Manager
Applied Data Systems
www.applieddata.net

"Steven" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> If you have need to read data produced by a big-endian system (such as a
Palm database file), you might do as I did under the same circumstances. I
read the data into bytes arrays one field/value at a time and manually
reversed the bytes in the array. I then passed the reversed bytes into
bitconverter. I have had no trouble reading Palm databases this way for
quite a while.

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Jamie Macleod
That's what i do as well.

"Steven" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> If you have need to read data produced by a big-endian system (such as a
Palm database file), you might do as I did under the same circumstances. I
read the data into bytes arrays one field/value at a time and manually
reversed the bytes in the array. I then passed the reversed bytes into
bitconverter. I have had no trouble reading Palm databases this way for
quite a while.

Reply to this message...
Vote that this is a GOOD answer...
 
First volume of Multimobile Development nearly ready to go to press
A mention on Developing for the iPhone and Android: The pros and cons
 
 
System.BitConverter
System.Console




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734