ByteVector String::data(Type t) const - SystemByteOrder
Festus Hagen
festushagenlists at yahoo.com
Tue Jan 21 11:44:19 UTC 2014
Hi all,
Asking cause I don't know!
Couldn't Utils::SystemByteOrder be followed here.
ByteVector String::data(Type t) const
{
.
. Wacked for brevity
.
case UTF16:
{
ByteVector v(2 + size() * 2, 0);
char *p = v.data();
// Assume that if we're doing UTF16 and not UTF16BE that we want little
// endian encoding. (Byte Order Mark)
*p++ = '\xff';
*p++ = '\xfe';
for(std::wstring::const_iterator it = d->data->begin(); it != d->data->end(); it++) {
*p++ = static_cast<char>(*it & 0xff);
*p++ = static_cast<char>(*it >> 8);
}
return v;
}
.
. Wacked for brevity
.
}
}
Maybe something like:
if (Utils::SystemByteOrder == Utils::LittleEndian) {
*p++ = '\xff';
*p++ = '\xfe';
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
*p++ = static_cast<char>(*it & 0xff);
*p++ = static_cast<char>(*it >> 8);
}
} else {
*p++ = '\xfe';
*p++ = '\xff';
for(wstring::const_iterator it = d->data.begin(); it != d->data.end(); it++) {
*p++ = static_cast<char>(*it >> 8);
*p++ = static_cast<char>(*it & 0xff);
}
}
Thanks
-Enjoy
fh : )_~
More information about the taglib-devel
mailing list