<div>Lukas,</div><div><br></div><div>then may I suggest using this code in the String::prepare() method of tstring.cpp, replacing the current case UTF16: block?</div><div><br></div><div><div> <font class="Apple-style-span" face="'courier new', monospace" size="1">case UTF16:</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"> {</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> if(d->data.size() >= 1 && (d->data[0] == 0xfeff || d->data[0] == 0xfffe)) {</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"> bool swap = d->data[0] != 0xfeff;</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1">#ifndef __ANDROID__ </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"> // ORIGINAL TAGLIB CODE. </font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> d->data.erase(d->data.begin(), d->data.begin() + 1);</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1">#else </font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> // ERASE FUNCTION RESPONSIBLE FOR DUPLICATE CHARACTER ON SOME POSITION OF STRING</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"> // CIRCUMVENTED BY THIS LOOP FOR NOW (bug reported to developer of Crystax NDK R5)</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> for(uint i =0; i < d->data.size()-1; i++){</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>d->data[i] = d->data[i+1];</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> } </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"> d->data.resize(d->data.size()-1);</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1">#endif </font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"> </font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> if(swap) {</font></div><div>
<font class="Apple-style-span" face="'courier new', monospace" size="1"> for(uint i = 0; i < d->data.size(); i++){</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> d->data[i] = byteSwap((unsigned short)d->data[i]);</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="'courier new', monospace" size="1">        </font></span></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"> }</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> }</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> else {</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"> debug("String::prepare() - Invalid UTF16 string.");</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> d->data.erase(d->data.begin(), d->data.end());</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace" size="1"> }</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> break;</font></div><div><font class="Apple-style-span" face="'courier new', monospace" size="1"> }</font></div>
</div><div><br></div><br clear="all">Greets,<div> Martijn van Rheenen</div><br>
<br><br><div class="gmail_quote">2011/4/19 Lukáš Lalinský <span dir="ltr"><<a href="mailto:lalinsky@gmail.com">lalinsky@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, Apr 19, 2011 at 9:22 AM, Martijn van Rheenen <<a href="mailto:rheenen@gmail.com">rheenen@gmail.com</a>> wrote:<br>
> Now in TagLib, in the file tstring.cpp, the wstring::erase() method is used,<br>
> which is NO problem ofcourse with native Linux/Windows development and I<br>
> guess any other platform for now, but with Crystax it fails to properly move<br>
> all characters of the resulting string. The workaround I found, for now, is<br>
> this:<br>
> ...<br>
> void String::prepare(Type t)<br>
> {<br>
> switch(t) {<br>
> case UTF16:<br>
> {<br>
> if(d->data.size() >= 1 && (d->data[0] == 0xfeff || d->data[0] ==<br>
> 0xfffe)) {<br>
> bool swap = d->data[0] != 0xfeff;<br>
><br>
> // ORIGINAL TAGLIB CODE. ERASE FUNCTION RESPONSIBLE FOR DUPLICATE<br>
> CHARACTER ON 6TH POSITION OF STRING USING CRYSTAX<br>
> //d->data.erase(d->data.begin(), d->data.begin() + 1);<br>
><br>
> // FIX FOR CRYSTAX R5 SDK:<br>
> for(uint i =0; i < d->data.size()-1; i++){<br>
> d->data[i] = d->data[i+1];<br>
> }<br>
> d->data.resize(d->data.size()-1);<br>
> ...<br>
> Note that I also could not use the 'wstring::copy()' method either, it<br>
> produces the same bug...<br>
<br>
</div>What about std::copy()?<br>
<div class="im"><br>
> Is there perhaps a way to implement this 'workaround' without having to<br>
> change an internal class of TagLib, with which nothing is wrong? Because I<br>
> wouldn't dare to ask to include this change in the official sourcecode, with<br>
> precompiler directive or not, since it's not a bug of TagLib itself... or<br>
> should I? ;)<br>
<br>
</div>I don't see why not. I'd prefer to use wstring::erase() normally, but<br>
if there is a macro that Crystax defines that you can check, we can<br>
conditionally use this code.<br>
<br>
Lukas<br>
_______________________________________________<br>
taglib-devel mailing list<br>
<a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/taglib-devel" target="_blank">https://mail.kde.org/mailman/listinfo/taglib-devel</a><br>
</blockquote></div><br>