-
September 20th, 2002, 03:36 AM
#1
Byte Conversion
I have a Problem with bytes.wstring in windows is 2 bytes & in linux 4 bytes.
In windows Iam doing as follows:
"Text" is of type Wstring.
char buffer[1];
int len = Text.size()*2;
// Converting to char
char *p = (char*)Text.c_str();
// here an algoritham,so that Iam taking the 1st 2 bytes .Iam doing this because,I want to swap the bytes(Little to BigEndian).& Iam writing it to stream.
for(int i=1; i<=len; i+=2)
{
for(int j =0;j<=1;j++)
{
buffer[j] = *p;
p++;
if (j ==1)
{
stream.write((Little2BigEndian(buffer,2)),2);
}
}
}
Little2BigEndian Function Does the swap.So In linux I want to convert the 4 bytes to bytes.How to do in accordance with my code .
Could any one Help?
Thanks
-
September 20th, 2002, 03:55 AM
#2
Byte Conversion
You could try to program a function which finds out which operatign system is installed and dle your conversion accordingly.
-
September 20th, 2002, 03:58 AM
#3
Iam # defining for Linux & windows,Could any one tell it with a code snippet please
-
September 20th, 2002, 04:06 AM
#4
Byte Conversion
you can find a function for which finds out the Windows Version at:
http://msdn.microsoft.com/library/de...sinfo_49iw.asp
I don't know how it is for Linux.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|