473,769 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

convert from BIG-ENDIAN to LITTLE-ENDIAN

Hi,

I am looking for help, i would like to know how can i use the endian.h and
config.h to convert compiled files under solaris from BIG-ENDIAN to compiled
files LITTLE-ENDIAN.

I am working under linux debian 3.0 woody

Thank you for your help.
Jul 19 '05 #1
2 29013
hicham wrote:
Hi,

I am looking for help, i would like to know how can i use the endian.h and
config.h to convert compiled files under solaris from BIG-ENDIAN to compiled
files LITTLE-ENDIAN.

I am working under linux debian 3.0 woody

Thank you for your help.


Standard C++ has no header files named config.h and endian.h. So we
can't help with issues relating to those header files. Try a Solaris
newsgroup.

Converting from Big Endian to Little Endian involve swapping bytes.
You can either write your own or search the STL. There seems to
be very little code differences between writing your own function
and a library version; since swapping is that big of a function.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 19 '05 #2
> > I am looking for help, i would like to know how can i use the endian.h
and
config.h to convert compiled files under solaris from BIG-ENDIAN to compiled files LITTLE-ENDIAN.


uint8_t* input = ...;
uint32_t v = input[0] | (input[1] << 8) | (input[2] << 16) | (input[3] <<
24);

This sort of arrangement generally gets the job done, no matter what which
of those endianess architechture you're on. It's more complicated issue if
you want to please this NG regulars, since:

- C++ doesn't guarantee that datatypes have precisely 8, 16 or 32 bits on
them. On those machines you have to do this at bit-level, most modern
architechtures support 8-bit chars and generally char,short,int, long, etc.
are multiplies of 8 bits.

Hmmm, so you just need to get typedefs right for uint8_t and uint32_t, and
rest should work out okay. Even if this NG regulars find this statement
fundamentally flawed, this (shifting to build up larger word) is what you
will find on most real-world UN*X sources for handling endianess.

The key is that you will have to know what endianess the stream/file is, so
that you can do the shifting of "input" in correct order. Some binary files
store values in big-endian (.lwo for example) and some in little-endian
(.3ds, for example). There is also BCP (?) endianess, which is rarely seen
in real-world since the platforms are novadays obsolete, so it's safe to
ignore those (again, stating this with NG regular disclaimer).
--
-xXx-
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
7288
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' + str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
5
2876
by: Son KwonNam | last post by:
I have some very huge(4~600MB) XML file which is in XML Native database - eXcelon. The problem is that I need to convert all the xml elements' names to lowercase. I think I could do this with XSLT. But the problem is that it's too big XML. Speed doesn't matter.
3
7773
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a DB and display it onscreen. No matter which way I open the file, convert it to Unicode/leave it as is or what ever, I see all single bytes ok, but double bytes become 2 seperate single bytes. Surely there is an easy way to convert these mixed...
4
3351
by: Guy | last post by:
I got a big Access file (1 400 tables) to convert to SQL and I would like to be provided with some automated tools, except upsizing wizard and DTS, to convert it on my own. I got a lot of forms and query to convert too. Can someday provide me with at least one tool name ? Thanks,
3
14522
by: Chua Wen Ching | last post by:
I have a problem. But on .NET 1.1 My Scenario: Actually I will have a string of hexadecimals read from a xml file. Then from the hexadecimals, i will add 1 value whenever i made any modifications. But just i do not how to get started. It is like an incremental hexadecimals. I have a string of hex. string strHex = "0100000000FF";
2
4239
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with this. Also - the citrix folks do not want us to keep the FE in Access as the queries and other activities consume a lot of power. The users will be in 3 different offices across the globe all accessing the 1 Oracle DB in Citrix. Does anyone have...
43
8458
by: Steven T. Hatton | last post by:
http://public.research.att.com/~bs/bs_faq2.html#int-to-string Is there no C library function that will take an int and convert it to its ascii representation? The example Bjarne shows in his faq is not extremely convenient. -- NOUN:1. Money or property bequeathed to another by will. 2. Something handed down from an ancestor or a predecessor or from the past: a legacy of religious freedom. ETYMOLOGY: MidE legacie, office of a deputy,...
35
4926
by: Abandoned | last post by:
I want to convert a string to command.. For example i have a string: a="" I want to do this list.. How can i do ?
4
1005
by: John Salerno | last post by:
Just curious if people put up any resistance to 2.0 like some people do for 3.0. Was it as big of a change in the language, or was the transition smoother? It seems silly for anyone to say they would prefer to stick with 1.x versions at this point, so perhaps we'll get there with 3.0 eventually too. Anyway, I'm just trying to figure out if the whole "I don't like 3.0" mentality (of some people, not all of course) is merely a result of it...
0
10051
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8879
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.