strings and endianness
spam at example.com
Wed Jan 18 11:40:33 PST 2012
I'm currently finishing std.uuid (see
http://prowiki.org/wiki4d/wiki.cgi?ReviewQueue ). For name based hashes, a
name string is passed to a hash function and I need to make sure that the
resulting hash is the same on both little endian and big endian systems. So
what's needed to convert a string to e.g little endian?
string --> as string is basically a byte array, is byte swapping even
wstring --> read as shorts and swap using nativeToLittleEndian()?
dstring --> read as ints and swap using nativeToLittleEndian()?
Also remotely related questions: AFAIK http://www.ietf.org/rfc/rfc4122.txt
doesn't exactly specify what encoding/byte order should be used for the UUID
names? Does this mean different implementations are allowed to generate
different UUIDs for the same input? (See chapter 'Algorithm for Creating a
RFC4122 also says "put the name space ID in network byte order.", but the
namespace is a ubyte, so how should this work?
Should name based UUIDs be different if they were created with the same
name, but using different encodings(string vs wstring vs dstring)? That's
the way boost.uuid implements it.
More information about the Digitalmars-d-learn