On 2/16/07, Theodore H. Smith <[EMAIL PROTECTED]> wrote:
> From: "Peter K. Stys" <[EMAIL PROTECTED]>
> I too have run into this problem with my new UB builds (I use custom
> plugins that write to memblocks complicating even further).
>
> The obvious solution is to set m.LittleEndian = false to mimic
> PPC-style endianness on all platforms.  Is this the "correct" way of
> dealing with endianness?  Importantly, is there a performance hit when
> running on Intel and having PPC-style bigendian memblocks
> (byte-swapping)?
>
> What about files (eg. memblocks dumped to a binary file) written to
> disk from a PPC version of my app then read in on an Intel version?
> what about a PPC version running under Rosetta on Intel?
>
> Why the heck did Intel and Motorola/Apple/IBM not decide on the same
> endianness 30 years ago for crying out loud?
>
> This is becoming a nightmare.

Why not just process your strings as UTF-8? Reading and writing UTF-8
has no encoding problem.

You only need UTF-16 for reading and writing to files that must be
UTF-16.

For writing it's simple, you just convert to UTF-16, and it's the
correct one for your platform.

For reading, it's a bit more complex as the endian may not be the
correct one for your platform. ElfData can help you here, it will
automatically detect the correct encoding for you, assuming the first
4 characters of your text is ascii, as is the case for XML. Or if
you've written a BOM, then ElfData will detect that. ElfData will
convert for you also. Just do this:

dim e as ElfData
e = s // s is a string
e.EncodingXMLGuess // can detect your encoding if it is XML or the
first 4 characters are ASCII!!!
s = e.ConvertToUTF8

A BOM is some official Unicode "mark" to signify what encoding you
are using.


My data have nothing to do with strings - it's all raw binary image
data, so UTF-8 etc.  does not enter into the equation.

P.


--
-------------------------------------------------------------------------------
Peter K. Stys, MD
Professor of Medicine(Neurology), Senior Scientist
Ottawa Health Research Institute, Div. of Neuroscience
Ottawa Hospital / University of Ottawa
Ontario, CANADA
tel:    (613)761-5444
fax:    (613)761-5330
http://www.ohri.ca/profiles/stys.asp
-------------------------------------------------------------------------------
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to