NOT a bug in TagLib, more in the Android SDK for now...

Martijn van Rheenen rheenen at gmail.com
Tue Apr 19 11:55:27 CEST 2011


Lukas,

then may I suggest using this code in the String::prepare() method of
tstring.cpp, replacing the current case UTF16: block?

  case UTF16:
  {
    if(d->data.size() >= 1 && (d->data[0] == 0xfeff || d->data[0] ==
0xfffe)) {
      bool swap = d->data[0] != 0xfeff;
#ifndef __ANDROID__
      // ORIGINAL TAGLIB CODE.
      d->data.erase(d->data.begin(), d->data.begin() + 1);
#else
      // ERASE FUNCTION RESPONSIBLE FOR DUPLICATE CHARACTER ON SOME POSITION
OF STRING
      // CIRCUMVENTED BY THIS LOOP FOR NOW (bug reported to developer of
Crystax NDK R5)
      for(uint i =0; i < d->data.size()-1; i++){
 d->data[i] = d->data[i+1];
      }
      d->data.resize(d->data.size()-1);
#endif

      if(swap) {
        for(uint i = 0; i < d->data.size(); i++){
          d->data[i] = byteSwap((unsigned short)d->data[i]);
 }
       }
    }
    else {
      debug("String::prepare() - Invalid UTF16 string.");
      d->data.erase(d->data.begin(), d->data.end());
    }
    break;
  }


Greets,
  Martijn van Rheenen



2011/4/19 Lukáš Lalinský <lalinsky at gmail.com>

> On Tue, Apr 19, 2011 at 9:22 AM, Martijn van Rheenen <rheenen at gmail.com>
> wrote:
> > Now in TagLib, in the file tstring.cpp, the wstring::erase() method is
> used,
> > which is NO problem ofcourse with native Linux/Windows development and I
> > guess any other platform for now, but with Crystax it fails to properly
> move
> > all characters of the resulting string. The workaround I found, for now,
> is
> > this:
> > ...
> > void String::prepare(Type t)
> > {
> >   switch(t) {
> >   case UTF16:
> >   {
> >     if(d->data.size() >= 1 && (d->data[0] == 0xfeff || d->data[0] ==
> > 0xfffe)) {
> >       bool swap = d->data[0] != 0xfeff;
> >
> >       // ORIGINAL TAGLIB CODE. ERASE FUNCTION RESPONSIBLE FOR DUPLICATE
> > CHARACTER ON 6TH POSITION OF STRING USING CRYSTAX
> >       //d->data.erase(d->data.begin(), d->data.begin() + 1);
> >
> >       // FIX FOR CRYSTAX R5 SDK:
> >       for(uint i =0; i < d->data.size()-1; i++){
> > d->data[i] = d->data[i+1];
> >       }
> >       d->data.resize(d->data.size()-1);
> > ...
> > Note that I also could not use the 'wstring::copy()' method either, it
> > produces the same bug...
>
> What about std::copy()?
>
> > Is there perhaps a way to implement this 'workaround' without having to
> > change an internal class of TagLib, with which nothing is wrong? Because
> I
> > wouldn't dare to ask to include this change in the official sourcecode,
> with
> > precompiler directive or not, since it's not a bug of TagLib itself... or
> > should I? ;)
>
> I don't see why not. I'd prefer to use wstring::erase() normally, but
> if there is a macro that Crystax defines that you can check, we can
> conditionally use this code.
>
> Lukas
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/taglib-devel/attachments/20110419/7ef6dbf4/attachment.htm 


More information about the taglib-devel mailing list