behaviour of bytevector
Lukáš Lalinský
lalinsky at gmail.com
Wed Apr 21 22:22:40 CEST 2010
On Wed, Apr 21, 2010 at 10:06 PM, Matthieu Riolo
<matthieu.riolo at googlemail.com> wrote:
> String::String(const ByteVector &v, Type t)
> {
> d = new StringPrivate;
> if(v.isEmpty())
> return;
> if(t == Latin1 || t == UTF8) {
> int length = 0;
> d->data.resize(v.size());
> wstring::iterator targetIt = d->data.begin();
> for(ByteVector::ConstIterator it = v.begin(); it != v.end() && (*it);
> ++it) {
> *targetIt = uchar(*it);
> ++targetIt;
> ++length;
> }
> d->data.resize(length);
> }
>
> If I see that correct is the check && (*it) a bit too much. Because the
> input is a ByteVector it should be clear that the binary can contain NULL
> values. But it should not matter as long we get the size (and this one we
> always have). I guess it was copy&pasted from the other constructors?
No, TagLib::String does not represent binary data, it represents
characters (Unicode code points) and stopping on a NULL byte is the
expected behavior.
As I asked in the other email, why are you converting the ByteVector
into a String?
Lukas
More information about the taglib-devel
mailing list