Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 7th, 2004, 3:47 AM   #1
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Alright, so I am writing a server client application that has to work cross platform, between Windows and linux. Now the deal is that the server and client can run on both platforms which makes managing the conversions a little more difficult.

To start off explaining this problem I am going to post a bit of output from some code I wrote to give me the sizes of a few various type on both linux and Windows.

Size of types in linux (gcc 2.3.3/gentoo 1.4rc1):
-------------------------------------------------

Sizeof: bool      1
Sizeof: int       4
Sizeof: unsigned int  4
Sizeof: long      4
Sizeof: double     8
Sizeof: float      4
Sizeof: unsigned char  1
Sizeof: char      1
Sizeof: wchar_t     4


Size of type in windows (MSVC++.net 2003), Windows XPsp2:
---------------------------------------------------------

Sizeof: bool      1
Sizeof: int       4
Sizeof: unsigned int  4
Sizeof: long      4
Sizeof: double     8
Sizeof: float      4
Sizeof: unsigned char  1
Sizeof: char      1
Sizeof: wchar_t     2

As you can see they are all pretty much the same, except wchar_t. On linux it is 4 bytes, I presume that it is using USC4 (if I recall correctly, I have this written down somewhere), however a quick googling has not really revealed to me what character encoding windows happens to be using... USC2? UTF16? And to make matter worse I have to figure out how to transfer all this data and preserve to data.

The most obvious, and probably best solution considering transfers will occure over a network is just to use the local setting and encode all the streams in UTF8 format before transferring since this tends to take less bandwidth when using latin based languages an characters and should provide an easy means for converting between most UCS and UTF formats.

Anyway, if anyone can tell me what format windows is using that is causing wchar_t to be represented by a 2 byte array I would greatly appreciate it, and maybe some info on converting between the two operating system.

Thanks....
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Old Jul 7th, 2004, 3:49 AM   #2
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Oh yeah, one thing I wanted to mention on top of that is that the 2byte representation of wchar_t is present when the application was compiled with MSVC.net 2003 (version 7) with MultiByte (MBCS) and UNICODE character sets enabled, the results were the same.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC